Posts Tagged ‘linear search standard algorithm’

Standard Algorithm 2 – Linear Search

November 30, 2007

This algorithm asks the user for something to look for and then checks through a list of items to see if it can find it. If it does find it, the algorithm says in what position it found it. So for example from the following list:

“Stewart”, “Simon”, “Dara”, “Scott”, “Keith”, “Farooq”, “Gaetano”

User Input Algorithm Output

Stewart 1

Dara 3

Gaetano 7

In the same way as the last standard algorithm you need to be able to write the pseudocode in the exam!

1.1 ask for item being searched for


1.2 for each item in the array


1.3 if this item matches the item being searched for

1.4 store the position


1.5 end if


1.6 end loop


1.7 print out where the item was found


Powerpoint below: