Given an ascending order array, build a balanced Binary Search Tree
1. Choose the middle element from the array
2. Create parent node with the middle element
3. Recur the left subarray and Recur the right subarray
4. Stop if the array have only one element

Note: the algorithm is very similar to merge sort when the tree is built
middle element is used instead of pivot element
class Stack{
        int maxLen;
        int count;
        char* array;
        Stack(int max){
            count = 0;
            maxLen = max;
            array = new char[maxLen];
        void push(char ch){
            if(count < maxLen){
                array[count] = ch;
        char pop(){
            char ch;
            if(count > 0){
                ch = array[count-1];
            return ch;
        bool isEmpty(){
            return count == 0;
        int size(){
            return count;
                delete[] array;