Searching means finding an element in an array. There are two ways to search an array linear search for an unsorted array and binary search(iterative or recursive) for a sorted array.

Linear Search

It is linearly transversing through the whole array and seeing if the element is there or not. The time complexity is O(n), and the space complexity is O(1).

Binary Search

Binary search is a technique used to search elements in a sorted array in O(log(n)) time complexity. Many problems can be solved by using slight variations of binary search.

Iterative Binary Search

--

--