Binary Search - Bubble Sort - Algrithm and Data Structure
Binary Search - Bubble Sort - Algrithm and Data Structure
Setting pointers
Binary Search Working
3. Find the middle element mid of the array ie. arr[(low + high)/2] = 6.
Mid element
Binary Search Working
3. If x == mid, then return mid.Else, compare the element to be searched with m.
4. If x > mid, compare x with the middle element of the elements on the right side of
mid. This is done by setting low to low = mid + 1.
5. Else, compare x with the middle element of the elements on the left side of mid.
This is done by setting high to high = mid - 1.
Binary Search Working
7. Repeat steps 3 to 6 until low meets high.
Binary Search Working
8. x = 4 is found.
In Coding General
Iteration Method
In Python In PYTHON
Binary Search Complexity
Time Complexities
Space Complexity