Computes the diameter of binary tree with given root. */
| 28 | |
| 29 | /* Computes the diameter of binary tree with given root. */ |
| 30 | int diameter(Node *root) |
| 31 | { |
| 32 | if (root == NULL) |
| 33 | return 0; |
| 34 | int ans = INT_MIN; // This will store the final answer |
| 35 | height(root, ans); |
| 36 | return ans; |
| 37 | } |
| 38 | |
| 39 | struct Node *newNode(int data) |
| 40 | { |