Open In App

Searching Algorithms

Last Updated : 13 Apr, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

Searching algorithms are essential tools in computer science used to locate specific items within a collection of data. In this tutorial, we are mainly going to focus upon searching in an array. When we search an item in an array, there are two most common algorithms used based on the type of input array.

  • Linear Search : It is used for an unsorted array. It mainly does one by one comparison of the item to be search with array elements. It takes linear or O(n) Time.
  • Binary Search : It is used for a sorted array. It mainly compares the array's middle element first and if the middle element is same as input, then it returns. Otherwise it searches in either left half or right half based on comparison result (Whether the mid element is smaller or greater). This algorithm is faster than linear search and takes O(Log n) time.

One more common search technique is Two Pointers Technique where we begin searching from both ends of the array.

Library Implementations of Binary Search

Easy Problems

Medium Problems

Hard Problems


More Searching Algorithms

Comparisons Between Different Searching Algorithms

Quick Links:


Article Tags :
Practice Tags :

Similar Reads