Searching Algorithms

  • Last Updated : 31 Aug, 2022

Searching Algorithms are designed to check for an element or retrieve an element from any data structure where it is stored. Based on the type of search operation, these algorithms are generally classified into two categories:

  1. Sequential Search: In this, the list or array is traversed sequentially and every element is checked. For example: Linear Search.
  2. Interval Search: These algorithms are specifically designed for searching in sorted data-structures. These type of searching algorithms are much more efficient than Linear Search as they repeatedly target the center of the search structure and divide the search space in half. For Example: Binary Search.

Linear Search to find the element “20” in a given list of numbers

Linear Search

Binary Search to find the element “23” in a given list of numbers

Binary Search
Topic :

Searching Algorithms :



Library Implementations of Searching Algorithms :

Coding Problems :

  1. Find the Missing Number
  2. Search an element in a sorted and rotated array
  3. Median of two sorted arrays
  4. Two elements whose sum is closest to zero
  5. Find the smallest and second smallest element in an array
  6. Maximum and minimum of an array using minimum number of comparisons
  7. k largest(or smallest) elements in an array | added Min Heap method
  8. Ceiling in a sorted array
  9. Count number of occurrences (or frequency) in a sorted array
  10. Find the repeating and the missing | Added 3 new methods
  11. Find a Fixed Point in a given array
  12. Find the maximum element in an array which is first increasing and then decreasing
  13. Find a pair with the given difference
  14. Find the k most frequent words from a file
  15. Median of two sorted arrays of different sizes
  16. Find a peak element
  17. Given an array of of size n and a number k, find all elements that appear more than n/k times
  18. Find the minimum element in a sorted and rotated array
  19. Kth smallest element in a row-wise and column-wise sorted 2D array | Set 1
  20. Find k closest elements to a given value
  21. Search in an almost sorted array
  22. A Problem in Many Binary Search Implementations
  23. Find the first repeating element in an array of integers
  24. Find common elements in three sorted arrays
  25. Count 1’s in a sorted binary array
  26. Given a sorted array and a number x, find the pair in array whose sum is closest to x
  27. Find the closest pair from two sorted arrays
  28. K’th Smallest/Largest Element in Unsorted Array | Set 1
  29. K’th Smallest/Largest Element in Unsorted Array | Set 2 (Expected Linear Time)
  30. K’th Smallest/Largest Element in Unsorted Array | Set 3 (Worst Case Linear Time)
  31. Find position of an element in a sorted array of infinite numbers
  32. Given a sorted and rotated array, find if there is a pair with a given sum
  33. Find the largest pair sum in an unsorted array
  34. Find the nearest smaller numbers on left side in an array
  35. K’th largest element in a stream
  36. Find a pair with maximum product in array of Integers
  37. Find the element that appears once in a sorted array
  38. Find the odd appearing element in O(Log n) time
  39. Find the largest three elements in an array
  40. Search an element in an array where difference between adjacent elements is 1
  41. Find three closest elements from given three sorted arrays
  42. Find the element before which all the elements are smaller than it, and after which all are greater
  43. Binary Search for Rational Numbers without using floating point arithmetic
  44. Floor in a Sorted Array
  45. Third largest element in an array of distinct elements
  46. Second minimum element using minimum comparisons
  47. Queries for greater than and not less than
  48. Efficient search in an array where difference between adjacent is 1
  49. Print all possible sums of consecutive numbers with sum N
  50. Minimum time required to produce m items
  51. Make all array elements equal with minimum cost
  52. Check if there exist two elements in an array whose sum is equal to the sum of rest of the array
  53. Check if reversing a sub array make the array sorted
  54. Find all triplets with zero sum
  55. Search, insert and delete in an unsorted array
  56. Search, insert and delete in a sorted array
  57. Move all occurrences of an element to end in a linked list
  58. Search in an array of strings where non-empty strings are sorted
  59. Smallest Difference Triplet from Three arrays
  60. Best First Search (Informed Search)

Quick Links:

  1. ‘Practice Problems’ on Searching
  2. ‘Quizzes’ on Searching


If you like GeeksforGeeks and would like to contribute, you can also write an article and mail your article to See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or if you want to share more information about the topic discussed above.

My Personal Notes arrow_drop_up

Writing code in comment? Please use, generate link and share the link here.