This introduction covers Finding the Needle within Linear Search for GCSE Computer Science. Revise Linear Search in 3.1 Fundamentals of Algorithms for GCSE Computer Science with 15 exam-style questions and 8 flashcards. This topic shows up very often in GCSE exams, so students should be able to explain it clearly, not just recognise the term. It is section 2 of 8 in this topic. Use this introduction to connect the idea to the wider topic before moving on to questions and flashcards.
Finding the Needle
Looking for something in a list? You have two strategies. Linear search is like looking for a word in a dictionary by starting at page 1 and reading every word - simple but slow. Binary search is how you actually use a dictionary - open to the middle, decide if your word is before or after, then repeat. Binary is MUCH faster, but the dictionary must be alphabetical (sorted)!
Practice questions for Linear Search
How does a linear search work?
Describe how a linear search works on a list of n items. [3 marks]