鶹Լ

Serial search

Searching for a or value is the foundation of many computer . The most basic kind of search is a serial search.

are set up before the search begins. The search then starts with the first item and then moves to each item in turn, until either a match is found or it reaches the end of the data with no match found.

Example

Imagine that you have a of sales made to customers. You need to deliver the goods that customer number 150 has bought, so need to find their address in the database.

The criterion is set first - Find the address for customer 150.

A serial search will begin at customer 1 and will search through each customer in turn until it reaches customer 150. It will then output the address for this customer. If it does not find customer 150, a message will be output to say that the customer is not found.

In this would look like:

OUTPUT "Which customer number would you like to look up?"
INPUT user inputs customer number
STORE the user's input in the customer_number variable
counter = 0 
found = False
WHILE found = False and counter ≤ number_of_records:
	IF counter = customer_number THEN
		OUTPUT customer address
		found = True
    ELSE
	    add 1 to counter
    ENDIF
ENDWHILE
IF found = False THEN
    OUTPUT "Customer not found"
ENDIF

As a , this would look like:

A flowchart showing a serial search.