[algogeeks] Re: Element search in a matrix

2007-11-13 Thread Dave
Do a binary search in each row or column. If there are m rows and n columns, this is O(m log n) or O(n log m), respectively. Dave On Nov 13, 10: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?

[algogeeks] Re: Element search in a matrix

2007-11-13 Thread Gene
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