[algogeeks] Find an element in sorted matrix

2009-08-20 Thread nagendra kumar
How can we find an element in the matrix [n*n] which is sorted row wise and column wise in O(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] Re: Find an element in sorted matrix

2009-08-20 Thread Anil C R
A more general problem is discussed in Introduction to Algorithms by Cormen et al problem 6-3, although the running time is O(n)... nagendra kumar wrote: How can we find an element in the matrix [n*n] which is sorted row wise and column wise in O(log n).

[algogeeks] Re: Find an element in sorted matrix

2009-08-20 Thread Pramod Negi
I guess it is famous Younge Tableau Problem of tableau MxN and searching can be done in O(M+N). I doubt the problem can be solved in O(lgn) if no space constraint and no pre-processing constraint present. On Thu, Aug 20, 2009 at 9:42 PM, Anil C R cr.a...@gmail.com wrote: A more general problem

[algogeeks] Re: Check divisibility by 3

2009-08-20 Thread Ralph Boland
On Aug 16, 7:29 pm, Ralph Boland rpbol...@gmail.com wrote: On Aug 14, 1:45 am, richa gupta richa.cs...@gmail.com wrote: can we check the divisibility of a given number by 3 withoutusing operators like '/' or '%'. I want the efficient solution to this problem .. can someone help ??

[algogeeks] Re: Find an element in sorted matrix

2009-08-20 Thread ankur aggarwal
i can improve a bit.. my logic is that i will take the a[n/2][n/2] element (middle of the diagonal element) if (num_2_b_search a[n/2][n/2]) square sub matrix from a[0][0] till a[n/2][n/2] can be left out.. i mean divide the whole matrix in 4 half A B C D in my above case A is chopped off

[algogeeks] Re: Check divisibility by 3

2009-08-20 Thread sandeep jain
Richa, Did you see http://geeksforgeeks.org/?p=511 I think, above link provides the kind of solution you are looking for On Thu, Aug 20, 2009 at 11:33 PM, Ralph Boland rpbol...@gmail.com wrote: On Aug 16, 7:29 pm, Ralph Boland rpbol...@gmail.com wrote: On Aug 14, 1:45 am, richa gupta

[algogeeks] Re: Question asked in MS interview

2009-08-20 Thread Pawandeep
I think i hve figured out the actual answer . Suppose we maintain a queue of N words in the memory. With two things 1. front 2. rear As a new word enters (recognized by a space) - front = front.next; if(it is already there in the list ) ++frequency of occurence; else{ - temp = rear; -

[algogeeks] Re: Find an element in sorted matrix

2009-08-20 Thread ankur aggarwal
@pramod yeh u r rite.. On Thu, Aug 20, 2009 at 10:20 PM, Pramod Negi negi.1...@gmail.com wrote: I guess it is famous Younge Tableau Problem of tableau MxN and searching can be done in O(M+N). I doubt the problem can be solved in O(lgn) if no space constraint and no pre-processing

[algogeeks] Re: Find an element in sorted matrix

2009-08-20 Thread ankur aggarwal
i can improve a bit to O(n^(log 3 base4 )) --~--~-~--~~~---~--~~ 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,

[algogeeks] Re: Find an element in sorted matrix

2009-08-20 Thread Dufus
AFAIK, searching an element in sorted matrix (Young's Tableau) takes O (n) time. So I am not sure if O(logn) is actually possible. _dufus On Aug 20, 6:41 pm, nagendra kumar nagendra@gmail.com wrote: How can we find an element in the matrix [n*n] which is sorted row wise and column wise