/    /  Data Structures-Searching

Searching

 

Searching algorithms check elements or retrieve an element from a data structure. 

Based on search operations they can be divided into the following categories: 

  1. Sequential Search
  2. Interval Search

 

Sequential Search

The list is traversed sequentially, and all the elements are checked. One example of sequential search is linear search.

 

Interval Search

They are used to search in sorted data structures. It is more efficient than sequential search. One of the examples of interval search is a binary search

 

Linear search vs Binary search

Linear SearchBinary Search
It accesses the data in sequential order.It accesses the data randomly.
Data does not need to be sorted in linear search.Data needs to be sorted in binary search.
Time complexity is -O(n)Time complexity is O(log n). 

 

 

Reference

Searching