The question is to find out sum of distances between every two nodes of BinarySearchTree given that every parent-child pair is separated by unit distance. It is to be calculated after every insertion.

ex:

```
 ->first node is inserted..

      (root)

   total sum=0;

->left and right node are inserted

      (root)
      /    \
  (left)   (right)

   total sum = distance(root,left)+distance(root,right)+distance(left,right);
             =        1           +         1          +         2
             =     4

and so on.....

```

Solutions I came up with:

1. Brute-force. Steps:

	1. perform a DFS and track all the nodes : `O(n)`.
	2. Select every two nodes and calculate : `O(nC2)_times_O(log(n))=O(n2log(n))` distance between them using [Lowest Common Ancestor](http://www.geeksforgeeks.org/lowest-common-ancestor-in-a-binary-search-tree/) Method and add them up.Overall Complexity: `-O(n2log(n))`.
2. `O(nlog(n))`. Steps:-

	1. Before insertion perform DFS and track all nodes : `O(n)`.
	2. Calculate distance between the inserted node and : `O(nlog(n))`. the remaining nodes.
	3. Add the existing sum with the sum calculated in step 2Overall Complexity: `-O(nlog(n))`.

Now the question is "is there any solution exists of order of `O(n)`??