Sry for the above typo. Correct algo

A more efficient approach :
Suppose the array is M*N

fun(int i, int j)
if(a[i][j] == x)
   return;
mid1=(i+M-1)/2;
mid2=(j+N-1)/2;

if(abs(a[i][mid1] - x) < abs(a[mid2][j]) - x)
    return fun(i,mid1)
else
    return fun(mid2,j)



This algo can be easily modified to account for the case in which the
element does not exist

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to