@Harsha, Yes!, the bottom up approach is the best and avoids lot of repeated calculations.
Cheers, Vignesh On Jul 11, 10:13 am, Harshal <hc4...@gmail.com> wrote: > @vigneshr, no your method is not that efficient since you will be calling > IsBST for a node many times in the process. It will be O(nlogn) assuming > complete Binary Tree, Sunny's algorithm runs in O(n) time. > > > > > > > > > > On Sun, Jul 10, 2011 at 11:25 PM, vigneshr <rvignesh1...@gmail.com> wrote: > > I donno if my idea is efficient. > > I'll do a breath-first traversal and check IsBST on each node(modified > > to also get the count of nodes) > > So at each level, the largest BST is kept track of and end of the > > level, the largest subtree can be returned. > > If there is no BST at that level go down one level more. > > > -- > > 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. > > -- > Best Regards, > Harshal Choudhary > 7th Semester, CSE Dept. > NIT Surathkal, India. > "The road to knowledge runs through the land of confusion." > > Mobile: +91 9844667142 > Email : hc4...@gmail.com > <http://www.facebook.com/profile.php?id=1518764305> > <https://twitter.com/#!/harshal4342> > <http://www.linkedin.com/pub/harshal-choudhary/17/731/291> > <http://kkoolharshal.blogspot.com> -- 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.