option c will be correct
first iteration
i = 0 ,j = 9
k = (0 + 9)/2 = 4
Elements with duplicate values of “2” the condition if(Y[k] <x) becomes true
second iteration
i = 0 , j = k =4
k = (0 + 4)/2 = 2
Elements with duplicate values of “2” the condition if(Y[k] <x) becomes true
third iteration
i = 0, j = 2
k = (0 + 2)/2 = 1
Elements with duplicate values of “2” the condition if(Y[k] <x) becomes true
Fourth iteration:
I=0, j=k=1
K= (0+1)/2=0
The while condition is Y[k] != x && i < j is true
● The above program doesn’t work for the cases where element to be searched is the last element of Y[ ] or greater than the last element (or maximum element) in Y[ ].
● For such cases, program goes in an infinite loop because i is assigned value as k in all iterations, and i never becomes equal to or greater than j.
● So while condition never becomes false.