Linear Search is defined as a sequential search algorithm that starts at one end and goes through each element of a list until the desired element is found, otherwise the search continues till the end of the data set.
How Does Linear Search Algorithm Work?
Time Complexity
Best | Worst | |
---|---|---|
Time Complexity | 0(1) | o (n) |
Binary Search is defined as a searching algorithm used in a sorted array by repeatedly dividing the search interval in half. The idea of binary search is to use the information that the array is sorted and reduce the time complexity to O(log N).
Conditions for Binary Search :
Time Complexity
Best | Worst | |
---|---|---|
Time Complexity | O(1) | O(log n) |
Space Complexity | O(1) Iterative | O(log n) Rec |
Binary Search Algorithm:
Ternary search is a search algorithm that is used to find the position of a target value within a sorted array. It operates on the principle of dividing the array into three parts instead of two, as in binary search.
Conditions
Time Complexity: $Log_3(n)$
<aside> 🎯 Binary search is faster than ternary search
</aside>
Like Binary Search, Jump Search is a searching algorithm for sorted arrays. The basic idea is to check fewer elements (than linear search) by jumping ahead by fixed steps or skipping some elements in place of searching all elements.
blockSize = sqrt(n)
How Does Jump Search Algorithm Work?
ARRAY = (0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610).
Find 55 with the following steps assuming that the block size to be jumped is 4.
The increasing order of performance is:
linear search < jump search < binary search
<aside>
Time Complexity: $O(\sqrt n)$
</aside>
The name of this searching algorithm may be misleading as it works in O(Log n) time. The name comes from the way it searches an element.