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
*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
dheerajsharma1...@gmail.comwrote:
1.How to
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 rock.ragha...@gmail.com wrote:
*you have to check for the braces where they have been used..in comman
brace that means they are
check this(considering valid input)
http://www.ideone.com/Nuhil
On Tue, Oct 4, 2011 at 3:36 PM, Dheeraj Sharma
dheerajsharma1...@gmail.comwrote:
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
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-datafind(tree-left,subtree-left)
find(tree-right,subtree-right)
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
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
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
will your code work for tree attached and for sum =40??
On Fri, May 14, 2010 at 11:44 PM, jalaj jaiswal
jalaj.jaiswa...@gmail.comwrote:
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
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
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
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;
}
12 matches
Mail list logo