We need all pairs. Best Regards, T V Thirumala Reddy
On Mon, Jul 11, 2011 at 3:56 PM, saurabh singh <[email protected]> wrote: > Ok lets see. > 1->Traverse a pointer right down to the leftmost element,i.e.the > shortest,say small > 2->traverse a pointer left down to the rightmost element i.e.the > largest.say large > while(small!=large) > 3->Compare their sum.If sum>k set large to its successor in reverse > inorder.(I am not sure if u meant the same but I am assuming rev inorder to > be right->node->left) > else set small to its inorder successor. > break when u get the desired k. > print :) > return > if u get out of the loop without getting the number > then such number does not exist.print :( > > > On Mon, Jul 11, 2011 at 3:16 PM, aanchal goyal > <[email protected]>wrote: > >> we should not deform the tree. >> - converting into dll and solving. >> - doing inorder and hashing >> - doing inorder and saving in array >> All above solutions I know, so dont post them, >> i dont know how to solve this using inorder and reverse inorder approach.. >> >> >> On Mon, Jul 11, 2011 at 3:13 PM, Piyush Sinha >> <[email protected]>wrote: >> >>> >>> If we dont want the tree back, we can convert the BST to DLL and do the >>> job.. >>> On Mon, Jul 11, 2011 at 3:01 PM, aanchal goyal <[email protected] >>> > wrote: >>> >>>> Given a BST and integer value K. Find all pairs of nodes (x,y), such >>>> that x->data + y->data = K >>>> Time O(n) >>>> >>>> Can someone provide a pseudocode/code to solve this using the concept of >>>> inorder and reverse inorder traversal of BST? >>>> PS: please don't post other solutions for this, I know this can be >>>> solved in other ways too. I am not able to code this using the above >>>> concept.. >>>> -- >>>> Regards,* >>>> Aanchal Goyal*. >>>> >>>> -- >>>> You received this message because you are subscribed to the Google >>>> Groups "Algorithm Geeks" group. >>>> To post to this group, send email to [email protected]. >>>> To unsubscribe from this group, send email to >>>> [email protected]. >>>> For more options, visit this group at >>>> http://groups.google.com/group/algogeeks?hl=en. >>>> >>> >>> >>> >>> -- >>> *Piyush Sinha* >>> *IIIT, Allahabad* >>> *+91-8792136657* >>> *+91-7483122727* >>> *https://www.facebook.com/profile.php?id=100000655377926 * >>> >>> -- >>> You received this message because you are subscribed to the Google Groups >>> "Algorithm Geeks" group. >>> To post to this group, send email to [email protected]. >>> To unsubscribe from this group, send email to >>> [email protected]. >>> For more options, visit this group at >>> http://groups.google.com/group/algogeeks?hl=en. >>> >> >> >> >> -- >> Regards,* >> Aanchal Goyal*. >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Algorithm Geeks" group. >> To post to this group, send email to [email protected]. >> To unsubscribe from this group, send email to >> [email protected]. >> For more options, visit this group at >> http://groups.google.com/group/algogeeks?hl=en. >> > > > > -- > Saurabh Singh > B.Tech (Computer Science) > MNNIT ALLAHABAD > > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > 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 [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
