VOOZH about

URL: https://www.geeksforgeeks.org/dsa/introduction-to-searching-algorithms-2/

⇱ Introduction to Searching - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Introduction to Searching

Last Updated : 23 Sep, 2025

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.

Basic Searching Algorithms:

Linear Search – O(n) Time and O(1) Space

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


Output
Element is present at index 3

Binary Search – O(log n) Time and O(1) Space

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.


Output
Element is present at index 3

Ternary Search – O(log₃ n) Time and O(1) Space

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}.


Output
2

Jump Search – O(√n) Time and O(1) Space

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 - O(n) Time and O(1) Space

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 - O(log n) Time and O(1) Space

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 – O(log n) Time and O(1) Space

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.

Comparison of Complexity Analysis of Searching Algorithms:

AlgorithmBest CaseAverage CaseWorst CaseSpaceRequirement
Linear SearchO(1)O(N)O(N)O(1)Works on any data
Binary SearchO(1)O(log N)O(log N)O(1)Sorted array needed
Ternary SearchO(1)O(log₃ N)O(log₃ N)O(1)Unimodal data
Jump SearchO(1)O(√N)O(√N)O(1)Sorted data
Interpolation SearchO(1)O(log log N)O(N)O(1)Uniform data
Fibonacci SearchO(1)O(log N)O(log N)O(1)Sorted data
Exponential SearchO(1)O(log N)O(log N)O(1)Sorted data
Comment
Article Tags:
Article Tags: