Given an array A of N elements you have to tell the height of BST constructed from this array by inserting the elements as nodes in BST, processing elements in the given order in the array.
Note:
1) In Binary Search Tree, the left sub-tree contains only nodes with values less than or equal to the parent node; the right sub-tree contains only nodes with values greater than the parent node.
2) Binary Search Tree with one node, has height equal to 1.
Constraints: :
1≤N≤103
1≤A[i]≤106
Format of the input file:
First line : N
Second line : N space separated integers denoting A[i].
Format of the output file:
Print the height of BST formed.
N=4.
Insert 2. It becomes root of the tree.
Insert 1. It becomes left child of 2.
Insert 3. It becomes right child of 2.
Insert 4. It becomes right child of 3.
Final height of tree = 3.