Diameter of Binary tree is longest path between two nodes. Write an efficient algorithm to find diameter of binary tree .
Suppose following nodes are inserted on binary tree.
Result : Diameter is 7
Longest path from two nodes.
View Nodes and pointers.
Try it Yourself
Program for how to find the diameter of a binary tree. iterative recursion time complexity O(n).
Visualize process Try it Yourself