Searching Algorithms

Linear Search

This simply checks the items one at a time.

Linear

Advantages

  • Does not require the data to be sorted.
  • Could be fast if the search item is towards the beginning of the list.

Disadvantages

  • Slow – each item may need to be checked.

Binary Search

Binary search repeatedly splits the list in 2 (Binary = 2) and checks the mid point of the smaller list.

Binary

Advantages

Faster as it splits the list in half on each iteration – in most cases there will be significantly fewer steps.

Disadvantages

The list needs to be sorted. If the list needs to be sorted the process may take more time overall.

 

%d bloggers like this: