Category Archives: Search Algorithms

Search Algorithms

Interpolation Search Algorithm

What Is Interpolation Search Algorithm?

Interpolation search is an efficient search algorithm for finding an item in a sorted list of items. Interpolation search algorithm works only on a sorted list of elements. In order to search an element using interpolation search algorithm, we must ensure that the list is sorted and evenly distributed. Interpolation search algorithm is a combination of both binary search and linear search algorithms. Interpolation search, also called as extrapolation search.

Interpolation Search Program In C

Output:-

Interpolation Search Algorithm

Jump Search Algorithm

Jump Search Algorithm

Jump Search Program In C

Output:-

Jump Search Algorithm

Binary Search Algorithm

What Is Binary Search Algorithm?

Binary search is one of the commonly used search algorithm in data structure. The Binary search is an efficient search algorithm for finding an item in a sorted list of items. Binary search algorithm works only on a sorted list of elements. In order to search an element using binary search algorithm, we must ensure that the list is sorted. When binary search is performed with a sorted list, the number of iterations can be reduced significantly.

How Binary Search Algorithm Works

Binary search algorithm is based on divide and conquer approach. In Binary search, an item is searched by comparing middle most element of the sorted list. If the search item is matched with the middle element of the list, then it returns the index of matched element. Otherwise, we check whether the given search item is smaller or larger than the middle element of the list. If the search item is smaller, then we will repeat this search process in the left sub-list to find the item. If the search item is greater, then we will repeat this search process in the right sub-list to find the item. 

At each step, we have reduced search space to find the target value because the list is sorted, We repeat this process until we find the search item in the list or we left with a sub-list consisting of a single element. And if the search item is not found in list then the “Search Item not found.” result is displayed.

Binary Search Program In C

Output:-

Binary Search Algorithm

Linear Search Algorithm

What Is Linear Search Algorithm?

Linear search algorithm is a simple search algorithm. Linear search algorithm is also known as sequential search algorithm. In this type of search algorithms, we simply search for an element or value in a given array by traversing the all array elements sequentially from the beginning of the array till the desired element or value is found. In Linear search, each array element is matched to find the desired search element. If a match found then location of the matched item is returned else it returns NULL.

Linear Search Program In C

Output:-

Linear Search Algorithm