http://www.geeksforgeeks.org/diameter-of-a-binary-tree/
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
using namespace std; struct node {
int data;
struct node *left, *right;
node() : data(), left(NULL), right(NULL) { }
node(int d) : data(d), left(NULL), right(NULL) { }
}; void print(node *node) {
if (!node) return;
print(node->left);
cout << node->data << " ";
print(node->right);
} int diameter(node *root, int &ans) {
if (!root) return ;
int l = diameter(root->left, ans);
int r = diameter(root->right, ans);
ans = max(ans, l+r+);
return max(l, r) + ;
} int main() {
struct node* root = new node();
root->left = new node();
root->right = new node();
root->left->left = new node();
root->left->right = new node();
int ans = ;
diameter(root, ans);
cout << ans << endl;
return ;
}