assume number is to found is n
this O(logn) solution
solution 2:
1 apply binary search on diagonal which return position (which element is
just greater then n) let supose return i;
2
int j1=binary(arr,i,N-1); // search in above row
if(j1!=-1) {printf("%d ,%d",i,j1);}
int j2=binary(arr,0,i-1); //search in next row
if(j2!=-1) {printf("%d ,%d",i,j1);}
NOTE : binary (int *arr[ROW],int left,int right) will return the position
of j or -1
--
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.