@Navneet: I think only saving the preorder traversal will do. O(n).
Inserting back into that order will give me the original tree back..
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to
@ Navneet: See if the tree is: 6
4 7
3 5 8
Then the preorder traversal is : 6 4 3 5 7 8
And using this preorder traversal and inserting them in the tree one by
void search_path( root , int i )
{
static char str[100];
if(root == null)
return;
if( i == 0 )
str[i] = root-data;
else str[i] = str[i-1] + root-data; // Maintaining the cumulative
sum of all the sums till now.
if ( str[i] == value )
I think leftmost right cousin of 9 should be NULL. Because 8 is its
immediate brother, and not cousin.
--
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