A more efficient approach :
Suppose the array is M*N
i=j=0;
if(a[i][j] == x)
return;
mid1=(i+M-1)/2;
mid2=(j+N-1)/2;
if(a[i][mid1]==x || a[mid2][j])==x
if(abs(a[i][mid1] - x) < abs(a[mid2][j]) - x)
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/algogeeks?hl=en.