Serial search
Searching for a keywordAn important word that will help return accurate search results. or value is the foundation of many computer programSequences of instructions for a computer.. The most basic kind of search is a serial search.
criteriaSingular - criterion. A set of rules or conditions that must be met. Often used in searches. 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 databaseA data store designed in an organised way, making it easier to search for the information you need. 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 pseudocode Also written as pseudo-code. A method of writing up a set of instructions for a computer program using plain English. This is a good way of planning a program before coding. 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 flowchartA diagram that shows a process, made up of boxes representing steps, decision, inputs and outputs., this would look like: