@ajay:recursively count the number of nodes then use formula h=log2(number of nodes)
On Wed, Jun 16, 2010 at 5:39 AM, Amir hossein Shahriari < [email protected]> wrote: > here's a recursive solution > > int depth(Node n){ > if (n==NULL) > return 0; > else > return 1 + max( depth( n.right ) , depth( n.left ) ); > } > > calling depth(root) will yield the height of the tree > > On 6/15/10, ajay kumar <[email protected]> wrote: > > Write a pseudo code 4 that..using c/c++....... > > > > how can we find the depth(height) of BST ????????? > > > > -- > > 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]<algogeeks%[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]<algogeeks%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > > -- yezhu malai vaasa venkataramana Govinda Govinda -- 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.
