Comparison of Searching methods in Data Structures

In different cases, we perform different searching schemes to find some keys. In this section we will see what are the basic differences between two searching techniques, the sequential search and binary search.

Sequential SearchBinary Search
Time complexity is O(n)Time complexity is O(log n)
Finds the key present at first position in constant timeFinds the key present at center position in constant time
Sequence of elements in the container does not affect.The elements must be sorted in the container
Arrays and linked lists can be used to implement thisIt cannot be implemented directly into the linked list. We need to change the basic rules of the list to implement this
Algorithm is iterative in natureAlgorithm technique is Divide and Conquer.
Algorithm is easy to implement, and requires less amount of code.Algorithm is slightly complex. It takes more amount of code to implement.
N number of comparisons are required for worst case.Log n number of comparisons are sufficient in worst case.