Link Search Close Search Menu Expand Document

Binary Search

Binary Search is a searching algorithms which works on sorted array.
At every iteration it finds the middle element of the array using $mid = \frac{(low + high)}{2}$
If middle element is equal to the key, search stops.
If the middle element is greater than the key, search continues in the first half. Otherwise search continues in the second half.
It has best case complexity of O(1), average and worst case complexity of O(log n).





Back to top

Copyright © 2020-2021 Gajanan Bhat. All rights reserved.