On Nov 13, 11:11 am, geekko <[EMAIL PROTECTED]> wrote:
> Given a matrix all whose columns and rows are individually sorted, how
> do you search a number in it?

Of course there are many ways.  I assume you want to minimize work.

You can start in the upper right hand corner and go left or down in
successive moves depending on what you find.  The algorithm is O(m +
n).  The other poster's idea of binsearch in each column or row is
faster if the matrix is far from square, i.e.
m > n log m
or
n > m log n


--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/algogeeks
-~----------~----~----~----~------~----~------~--~---

Reply via email to