even if u maintain the size , u never know whats the size of child left-subtree and right subtree to evaluate.
can you explain the first appraoch ? On Wed, Dec 9, 2009 at 9:24 PM, Rohit Saraf <rohit.kumar.sa...@gmail.com>wrote: > u can maintain the size.. > and if you don't want that , at least memoize it.. it won't be O(n^2) then. > > Rohit Saraf > Sophomore > Computer Science and Engineering > IIT Bombay > > > > On Wed, Dec 9, 2009 at 9:12 PM, chitta koushik <koushik.infin...@gmail.com > > wrote: > >> Though i couldn't get both ur approaches clearly , guess 2nd approach shud >> take O(n^2) since you go to each node and find the size of left subtree . >> >> Or i shud be missing something. my bad can you explain your approaches >> clearly. >> >> On Wed, Dec 9, 2009 at 8:20 PM, Rohit Saraf >> <rohit.kumar.sa...@gmail.com>wrote: >> >>> do it iteratively either by: >>> >>> 1) If size of left tree is less than k, rotate the tree left. and so on >>> till .....single while loop required for this. >>> or >>> 2) Start from head, if k is more than size of left-tree, go to left and >>> continue searching.. other wise go right and search for k-size(left)-1 in >>> right tree. All this can be implemented in a single while loop. >>> >>> -- >>> 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.