Algorithms



Sequential Search

1. read N1, ..., N10,000, T1, ..., T10,000

2. read NAME

3. i <- 1

4. found <- false

5. repeat until either found or i > 10,000

6.    if NAME = Ni then

7.        write Ti

8.        found <- true

9.    else

10.      i <- i + 1

11. if not found then

12.    write "Sorry, but the name is not in the directory."

13. stop

Sequential search is the formal analogue of running your finger down a column of the phone book.

[Prev][TOC][Next]


CS1104 Main Page
Last Updated 01/05/2000
© L.Heath, 2000