Re: [algogeeks] Tree Question

2011-10-04 Thread shiva@Algo
check this(considering valid input) http://www.ideone.com/Nuhil On Tue, Oct 4, 2011 at 3:36 PM, Dheeraj Sharma wrote: > yeah..but am looking for code..that takes the input...as string of > (A(B(E(K,L),F),D(H(M,I),J))) > and returns head of tree.. > > > On Tue, Oct 4, 2011 at 2:11 PM, Raghav Garg

Re: [algogeeks] Tree Question

2011-10-04 Thread Dheeraj Sharma
yeah..but am looking for code..that takes the input...as string of (A(B(E(K,L),F),D(H(M,I),J))) and returns head of tree.. On Tue, Oct 4, 2011 at 2:11 PM, Raghav Garg wrote: > *you have to check for the braces where they have been used..in comman > brace that means they are on same level..i am p

Re: [algogeeks] Tree Question

2011-10-04 Thread Raghav Garg
*you have to check for the braces where they have been used..in comman brace that means they are on same level..i am providing answer to your problem in attached file.. check that out.. *Raghav garg On Tue, Oct 4, 2011 at 1:53 PM, Dheeraj Sharma wrote: > 1.How to construct a tree from the list

[algogeeks] Tree Question

2011-10-04 Thread Dheeraj Sharma
1.How to construct a tree from the list representation for ex.- construct tree from (A(B(E(K,L),F),D(H(M,I),J))) the tree would be binary the structure of the node would be struct node{ int data; struct node *left,*right; }; 2.Given a binary tree..give its list representaion..(reverse of abo

[algogeeks] TREE question

2011-08-13 Thread vicky S
Given 2 trees .Find wether second tree is the subtree of the first tree . here is my soln corect me if i m wrong: bool find(struct node * tree,struct node *subtree) { if(tree==NULL ) return ; if(tree->data==subtree->data && find(tree->left,subtree->left) && find(tree->right,subtree->righ

Re: [algogeeks] TRee question...

2011-08-12 Thread Dipankar Patro
What Deoki answered in valid for non-leaf node. Consider this tree: 3 / \ 4 5 / \ 6 7 According to Deoki's answer, 7's in-order successor is 4, which not correct. the answer should be 3. Here is the proper method (for leaf node only), Following Deoki's answer for non-leaf: - keep a

Re: [algogeeks] TRee question...

2011-08-12 Thread Deoki Nandan
if given node has right subtree then its inorder successor will be left most child of given node's right child. if given node does not have right child the its successor will be its parent On Fri, Aug 12, 2011 at 11:28 AM, Priyanka Goel < priyankatheinvinci...@gmail.com> wrote: > How to find the

[algogeeks] TRee question...

2011-08-11 Thread Priyanka Goel
How to find the in-order successor of a given node in a binary search tree where each node has a link to its parent. pl explain logic to solve it.. ( Pl dnt give solution of doing in order traversal and storing it in array.) -- You received this message because you are subscribed to the Google Gr

Re: [algogeeks] tree question

2010-05-16 Thread Rohit Saraf
Either the root will be included or it will not be. If it's not, then it's equivalent to solving the problem on the subtrees. So let's consider the case when root node is included Now we keep track of A[node1,node2,reqdWeight] reqdWeight is the sum of wt reqd from paths starting from node1 and nod

Re: [algogeeks] tree question

2010-05-16 Thread sharad kumar
will your code work for tree attached and for sum =40?? On Fri, May 14, 2010 at 11:44 PM, jalaj jaiswal wrote: > Strategy: subtract the node value from the sum when recurring down, > and check to see if the remaining sum is 0 when you run out of tree. > let sum be subsum > > int * PathSum(s

Re: [algogeeks] tree question

2010-05-14 Thread jalaj jaiswal
Strategy: subtract the node value from the sum when recurring down, and check to see if the remaining sum is 0 when you run out of tree. let sum be subsum int * PathSum(struct node* node, int sum) { int i=0; if (subsum == 0) { return(array); } elseif(node==NULL){ return; }

[algogeeks] tree question

2010-05-14 Thread divya
write a c code to print the path in a tree sum of whose nodes equals a given number.. -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email