Re: [algogeeks] Re: Construct Binary Tree From Ancestor Matrix

2011-03-30 Thread Tushar Bindal
a[i][j]=1 if 'i' is a parent to 'j'

But in your matrix,
a[1][2] = 1
a[1][3] = 1
a[2][3] = 1
a[4][2] = 1
a[4][3] = 1

You have taken 'j' to be a parent to 'i'


-- 
Tushar Bindal
Computer Engineering
Delhi College of Engineering
Mob: +919818442705
E-Mail : tusharbin...@jugadengg.com

-- 
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 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: Construct Binary Tree From Ancestor Matrix

2011-03-08 Thread bittu
@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 algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: Construct Binary Tree From Ancestor Matrix

2011-03-08 Thread saurabh agrawal
   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 shashank7andr...@gmail.com 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 algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 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 algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.