can you pls tell how will we apply seperatly on odd and even positions..?
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
25 |
1 |
17 |
5 |
13 |
10 |
9 |
23 |
6 |
30 |
suppose we want to search 25,then we will run 2 binary searches.
one from (1-9)i=1 and j=9 for odd and other for (2-10) for even.
now,lets take odd case,mid = 5 which is an odd position.25 > 13 ,so we should decrement value of J.now if i decrment value of j by mid -2,j becomes 3.i=1 and j=3 then mid =2 which is an even position.how should i go about it now?