From Higher Computing Science
- Linear search is an algorithm that checks an array for the presence of a particular item of data. To do this, the user must be asked what they are searching for. Each item in the array will be compared to the search term, and if the item is found, a message is displayed.
SET list TO [1,4,2,5,3] RECEIVE searchterm FROM (INTEGER) KEYBOARD FOR counter FROM 0 TO 4 DO IF list[counter]=searchterm THEN SEND (STRING) searchterm & " found at position " & (STRING) counter END IF END FOR