For example, you are given below matrix.
1 2 3 4
1 0 1 1 0
2 0 0 1 0
3 0 0 0 0
4 0 1 1 0
You need to construct the below tree. In the constructed tree ancestor relationship should be correct. A node can come on left or right of its parent as you cannot determine this information from the ancestor matrix
Node numbers used in matrix are in bracket
5(3)
/
/
10(2)
/ \
/ \
12(1) 13(4)
Data Structure Used: 2-D Array , Binary Tree
Algorithm
Time Complexity
Space Complexity
1 comment :
Any solution for this one?
Post a Comment