Linear Search
Computer Science: OCR A Level, topic 8.1.9
Linear Search
Linear search is one of the simplest searching algorithms.

The concept
- If you were looking for a specific piece of paper in a stack of papers, then one way to find it would be to work from the top of the stack to the bottom, checking each paper on the way.
- This is exactly how linear search works.

In English
- Check the first item in the dataset:
- If it is what we are looking for, return it.
- Check the second item in the dataset:
- If it is what we are looking for, return it.
- Continue for rest of items.
- If we reach the end of the data set, then the item was not in our data set.
,w_800.png)
Linear search pseudocode

Pros and cons of linear search
- Pros:
- Very easy to implement.
- Cons:
- Slow on a long list.
Test yourself on Linear Search
What is the main disadvantage of linear search?
Linear Search in English
Linear Search Pseudocode