vigneshk.cit
BAN USERya....correct....i support u
- vigneshk.cit June 21, 2010if in case of merging two BST....
take out nodes one by one in in-order...from both the trees
then compare the 2 node values...
then construct a new tree based on those values........
first find the length of te path from root to node1 using pointer1...
similarly find for node2 usng pointer2..
subtract both the pathlengths...
and tat gives how many times the pointer2 from te node2 has to be traversed back towards root....
after this both the pointers will b in te same level...
now just find the parent for either of te nodes...........and tis ll give the common ancestor for both the nodes
one simple way
1..first traverse the main list
2..while traversing compare the consecutive 2 nos..
3..put the smaller ones in newlist1
4..put the larger ones in newlist2
5..after reachin te end of te list,reverse te newlist2
6..merge newlist2 wit newlist1
......................................tatzall
can use the linked list for factorial
- vigneshk.cit June 20, 2010
need more explanations pls........
- vigneshk.cit August 06, 2010