![]() |
VOOZH | about |
Searching is the fundamental process of locating a specific element or item within a collection of data. This collection of data can take various forms, such as arrays, lists, trees, or other structured representations.
It is the simplest searching algorithm that checks each element sequentially until the key is found or the collection is fully traversed. Works on both sorted and unsorted data. For more details refer here.
For example: Consider the array arr[] = {10, 50, 30, 70, 80, 20, 90, 40} and key = 30
Element is present at index 3
It works on sorted arrays by repeatedly dividing the search interval in half. If the target matches the middle element, return it; otherwise, continue searching left or right. For more details refer here.
For example: Consider the array arr[] = {2, 5, 8, 12, 16, 23, 38, 56, 72, 91}, and the key = 23.
Element is present at index 3
Ternary Search is a variant of binary search that splits the search interval into three parts instead of two. Mostly used in searching unimodal functions. For more details refer here.
For example: Consider the array arr[] = {9,7,1,2,3,6,10}.
2
Jump Search is another searching algorithm that can be used on sorted collections (arrays or lists). The idea is to reduce the number of comparisons by jumping ahead by fixed steps or skipping some elements in place of searching all elements. For more details refer here.
Interpolation Search is an efficient searching algorithm for sorted collections of data, such as arrays or lists. It is an improvement over Binary Search, particularly when the data is uniformly distributed. For more details refer here.
Fibonacci Search is an efficient searching algorithm used for finding a target value in a sorted collection, such as an array or list. It is similar in principle to Binary Search but uses Fibonacci numbers to determine the positions to be compared. For more details refer here.
Exponential Search is a searching algorithm designed to find a target value in a sorted collection, such as an array or list. It combines elements of Binary Search and Linear Search to efficiently locate the target, especially when its position is near the beginning of the collection. For more details refer here.
| Algorithm | Best Case | Average Case | Worst Case | Space | Requirement |
|---|---|---|---|---|---|
| Linear Search | O(1) | O(N) | O(N) | O(1) | Works on any data |
| Binary Search | O(1) | O(log N) | O(log N) | O(1) | Sorted array needed |
| Ternary Search | O(1) | O(log₃ N) | O(log₃ N) | O(1) | Unimodal data |
| Jump Search | O(1) | O(√N) | O(√N) | O(1) | Sorted data |
| Interpolation Search | O(1) | O(log log N) | O(N) | O(1) | Uniform data |
| Fibonacci Search | O(1) | O(log N) | O(log N) | O(1) | Sorted data |
| Exponential Search | O(1) | O(log N) | O(log N) | O(1) | Sorted data |