Re: [algogeeks] Re: TRee question...

2011-08-14 Thread Dipankar Patro
Sorry about the tree, didn't keep in mind about BST while drawing that. But I think you all got the point that I was trying to point out. On 13 August 2011 23:18, rajul jain rajuljain...@gmail.com wrote: see WgpShashank second point carefully it say successor is parent of left node so

Re: [algogeeks] Re: TRee question...

2011-08-13 Thread Anika Jain
@ashmantak: the figure of dipankar is incorrect but his point is correct.. for a tree like 4 /\ 2 10 / \ 13 successor of 3 shall be 4 not 2.. On Fri, Aug 12, 2011 at 4:48 PM, ashmantak

Re: [algogeeks] Re: TRee question...

2011-08-13 Thread Anika Jain
It is the solution for inorder successor without having parent pointer.. node *inorder_succ(node *root, int x) { node *prev=NULL; node *p=findspcl(root,prev, x); if(p-r) { p=p-r; while(p-l) p=p-l; return p;

[algogeeks] Re: TREE question

2011-08-13 Thread Yasir
... if(something) return true; else return false; . // few statements here . Will few statements ever execute?? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit

Re: [algogeeks] Re: TRee question...

2011-08-13 Thread rajul jain
see WgpShashank second point carefully it say successor is parent of left node so solution of you BST is parent of 2 which is 4 On Sat, Aug 13, 2011 at 7:50 PM, Anika Jain anika.jai...@gmail.com wrote: @ashmantak: the figure of dipankar is incorrect but his point is correct.. for a tree like

Re: [algogeeks] Re: TREE question

2011-08-13 Thread aditya kumar
void find(struct node * tree,struct node *subtree) { if((tree==NULL )||(subtree==NULL)) return ; else { printf(the data being compared are tree:%d subtree:%d \n,tree-data,subtree-data); if((tree-data)==(subtree-data)) { flag=1; find(tree-left,subtree-left); find(tree-right,subtree-right); }

[algogeeks] Re: TRee question...

2011-08-12 Thread WgpShashank
@priya here is algorithm Algorithm: (With Using Parent Pointer ) 1) If right subtree of node is not NULL, then successor lies in right subtree. Do following. Go to right subtree and return the node with minimum key value in right subtree. 2) If right sbtree of node is NULL, then successor is

Re: [algogeeks] Re: TRee question...

2011-08-12 Thread ashmantak
@Dipankar Patro - The figure u have made isn't a BST.Read the problem. His soln. is correct. -- 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 group, send