Here is the question: Given an array of 1000 elements in sorted order what is the
largest possible value that will be printed when the array is
passed to method mystery?
And here is the mystery code
public int mystery(int[] v, int t) { int w = 0; int h = v.length - 1; int c = 0; while(w <= h) { c++; int m = (w + h) >>> 1; if(v[m] < t) {h = m - 1}; else if(v[m] > t) {w = m + 1}; else { System.out.print(c); return m; } } System.out.print(c); return -(w + 1); }
Could someone explain it to me how this is 9? It would be greatly appreciated.