@Anand: Agreed. But according to this problem only the leaves form the doubly linked list
On Sun, Jun 27, 2010 at 10:41 AM, Anand <anandut2...@gmail.com> wrote: > @ Raj: I have one doubt. The condition you gave for finding the height of > the tree satisfies on every node if tree is a doubly linked list. Correct me > if I missing out something > > > > On Sat, Jun 26, 2010 at 12:25 PM, Raj N <rajn...@gmail.com> wrote: > >> @jalaj: Use the same algorithm as finding the height of a normal tree (I >> hope you're familiar with it) . But to know that you've reached a leaf, you >> would normally use node->left or node->right ==NULL. But here in this case, >> the leaves form a doubly linked list, so the former condition can no longer >> be used and hence the condition becomes node==node->right->left which is >> nothing but node==node->next->previous in doubly linked list terminology. >> >> I hope this is clear. >> >> On Sun, Jun 27, 2010 at 12:48 AM, Raj N <rajn...@gmail.com> wrote: >> >>> @Algoose: Thanks for correcting it. Even I have made the same mistake as >>> Divya. It shud be node == node->right->left >>> >>> >>> On Sat, Jun 26, 2010 at 7:20 PM, Algoose Chase <harishp...@gmail.com>wrote: >>> >>>> If the parent Pointer is available we can use >>>> >>>> if( node->right->data > node->parent->data || node->right->data < >>>> node->data) to identify the leaf nodes and use it as one of the recursion >>>> terminating condition in the original Height determining Algorithm. >>>> >>>> @Divya, I think u meant node != node->right->left >>>> >>>> >>>> On Sat, Jun 26, 2010 at 3:54 PM, divya jain >>>> <sweetdivya....@gmail.com>wrote: >>>> >>>>> yes.. >>>>> >>>>> i got the solution traverse till node->right!=node->right->left... at >>>>> this point u ll get height.. rite? >>>>> >>>>> >>>>> On 26 June 2010 11:49, Raj N <rajn...@gmail.com> wrote: >>>>> >>>>>> @Divya: What will happen when say node->right when you reach the >>>>>> leaves ? Is it equivalent to node->next and node->left = = >>>>>> node->previous in >>>>>> the doubly linked list ? >>>>>> >>>>>> >>>>>> On Tue, Jun 22, 2010 at 4:44 PM, divya <sweetdivya....@gmail.com>wrote: >>>>>> >>>>>>> a bst is given whose leaf nodes having left as well as right pointers >>>>>>> not pointing to NULL. rather all the leaf nodes are forming a >>>>>>> circular >>>>>>> doubly linked list. u have to calculate height of tree. >>>>>>> >>>>>>> -- >>>>>>> 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 to >>>>>>> algogeeks+unsubscr...@googlegroups.com<algogeeks%2bunsubscr...@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 algoge...@googlegroups.com. >>>>>> To unsubscribe from this group, send email to >>>>>> algogeeks+unsubscr...@googlegroups.com<algogeeks%2bunsubscr...@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 algoge...@googlegroups.com. >>>>> To unsubscribe from this group, send email to >>>>> algogeeks+unsubscr...@googlegroups.com<algogeeks%2bunsubscr...@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 algoge...@googlegroups.com. >>>> To unsubscribe from this group, send email to >>>> algogeeks+unsubscr...@googlegroups.com<algogeeks%2bunsubscr...@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 algoge...@googlegroups.com. >> To unsubscribe from this group, send email to >> algogeeks+unsubscr...@googlegroups.com<algogeeks%2bunsubscr...@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 algoge...@googlegroups.com. > To unsubscribe from this group, send email to > algogeeks+unsubscr...@googlegroups.com<algogeeks%2bunsubscr...@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 algoge...@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.