Category Archives: Data Structure Tutorial

Data Structure Tutorial

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

Tim Sort Algorithm

Tim Sort Program In C

Output:-

tim_sort_program_in_c

Comb Sort Algorithm

Comb Sort Program In C

Output:-

comb_sort_program_in_c

Bucket Sort Algorithm

Bucket Sort Program In C

Output:-

bucket_sort_program_in_c

Cycle Sort Algorithm

Cycle Sort Program In C

Output:-

cycle_sort_program_in_c

Cocktail Sort Algorithm

Cocktail Sort Program In C

Output:-

cocktail_sort_program_in_c

Bitonic Sort Algorithm

Bitonic Sort Program In C

Output:-

bitonic _sort_program_in_c

Radix Sort Algorithm

Radix Sort Program In C

Output:-

radix_sort_program_in_c

Shell Sort Algorithm

Shell Sort Program In C

Output:-

shell_sort_program_in_c