1 2 3 4 1 0 1 1 0 2 0 0 1 0 3 0 0 0 0 4 0 1 1 0 Node numbers used in matrix are in bracket 5(3) | | 10(2) / \ / \ 12(1) 13(4) For every row in the matrix, calculate the number of non - zero numbers. This will give the level of that node in the tree. Now the node with level 0 is root. Traverse the root column[here 3] to find out where the root is set ( here column3 is set in 1,2,4 row ) and level is 1, so the answer is 2. Keep on increasing the level. TC O(n*n);
On Tue, Mar 8, 2011 at 7:24 PM, bittu <[email protected]> wrote: > @all where r u guys.. > > -- > 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. > > -- 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.
