In general, diameter of a tree is defined as the maximum distance between any 2 nodes in the tree. So, assuming h(x) is height of x(function), and d(x) is diameter of x(function), where x is any general node of the tree, d(root)=max((h(root->left)+h(root->right)+1),max(d(root->left),d(root->right))).
This gives diameter of the tree! On Mon, Jun 25, 2012 at 2:43 PM, Mohit Khanna < [email protected]> wrote: > What would be the diameter in case of a left skewed or right skewed tree? > > > > On Mon, Jun 25, 2012 at 12:48 PM, atul anand <[email protected]>wrote: > >> consider a case where tree is right skewed or left skewed , in dat case >> max distance b/w two node found are root and leftmost or rightmost >> node(left or right skewed) . so its not alwayzz true >> >> On Sun, Jun 24, 2012 at 5:08 PM, Navin Kumar <[email protected]>wrote: >> >>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "Algorithm Geeks" group. >>> To view this discussion on the web visit >>> https://groups.google.com/d/msg/algogeeks/-/xM3mGdcfvi4J. >>> 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. >> > > -- > 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.
