Skip to content

Commit c9aab53

Browse files
authored
Update README.md
1 parent c0f6abd commit c9aab53

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

Search/BinarySearch/README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Binary Search
1+
## Binary Search
22

33
Given a sorted array arr[] of n elements, write a function to search a given element x in arr[].
44
A simple approach is to do linear search.The time complexity of above algorithm is O(n). Another approach to perform the same task is using Binary Search.
@@ -10,6 +10,9 @@ The idea of binary search is to use the information that the array is sorted and
1010
We basically ignore half of the elements just after one comparison.
1111

1212
1.Compare x with the middle element.
13+
1314
2.If x matches with middle element, we return the mid index.
14-
3.Else If x is greater than the mid element, then x can only lie in right half subarray after the mid element. So we recur for right half.
15+
16+
3.Else If x is greater than the mid element, then x can only lie in right half subarray after the mid element. So we recur for right half.
17+
1518
4.Else (x is smaller) recur for the left half.

0 commit comments

Comments
 (0)