You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/*Binary search is another searching algorithm which is more effective than the linear Search. Searching algorithms are used to search a desired element in an array.Binary Search does less number of comparisons than linear Search,so it is an effective algorithm.Binary Search works only on sorted array. It follows divide and conquer approach.*/
3
+
4
+
/*algorithm
5
+
The array should be sorted.
6
+
We take 3 variables start,mid and end. Start variables has the index of 0th element end variable has index of last element and mid points to middle element.
7
+
We run a loop until start<=end.
8
+
We check if our desired element is equal to mid element.
9
+
If yes then return mid.
10
+
If desired element is greater than the mid element then we search in the right array.
11
+
If desired element is less than the mid element then we search in the left array.
0 commit comments