inordersucc(struct tree* p) { if(p->right !=NULL) return p->right; struct tree* ptr,*psuc; ptr=root;
while(ptr->info!=x->info) { if(x->info<ptr->info) { psuc=ptr; ptr=ptr->left; } else ptr=ptr->right; } return psuc; } On 8/6/11, Anuj Kumar <anuj.bhambh...@gmail.com> wrote: > i am sending the running code :) > > #include<iostream> > > using namespace std; > struct node > { > int data; > struct node *lc,*rc; > node(int d) > { > data=d;lc=rc=NULL; > } > }; > int ret,fl; > void inorder(struct node *root,int d) > { > if(ret==1)return; > if(root==NULL)return; > inorder(root->lc,d); if(ret==1)return; > if(fl==1){cout<<root->data;ret=1;} > if(root->data==d){fl=1;} > inorder(root->rc,d); if(ret==1)return; > } > int main() > { > struct node *root=new node(2); > root->lc=new node(1); > root->rc=new node(3); > root->rc->rc=new node(6); > ret=0;fl=0; > inorder(root,3); > return 0; > } > > On Sat, Aug 6, 2011 at 5:50 PM, Aman Goyal <aman.goya...@gmail.com> wrote: > >> .. pseudo code for finding inorder successor of a node without parent >> field.. >> >> -- >> 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 email to >> algogeeks+unsubscr...@googlegroups.com. >> For more options, visit this group at >> http://groups.google.com/group/algogeeks?hl=en. >> > > > > -- > Anuj Kumar > Third Year Undergraduate, > Dept. of Computer Science and Engineering > NIT Durgapur > > -- > 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 email to > algogeeks+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > > -- 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 email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.