void doInsert(int[] num, int s, int e, TreeNode p, Boolean left){
        if(left){	//left side
            if(e < s){
                return;
            }
            else if(e == s){
                TreeNode node = new TreeNode(num[s]);
                p.left = node;
            }
            else if(e == s + 1){
                TreeNode node = new TreeNode(num[e]);
                p.left = node;
                doInsert(num, s, s, node, true);
            }
            else{
                int mid = (s + e) / 2;
                TreeNode node = new TreeNode(num[mid]);
                p.left = node;
                doInsert(num, s, mid - 1, node, true);
                doInsert(num, mid + 1, e, node, false);
            }
        }
        else{	
            if(e < s){
                return;
            }
            else if(e == s){
                TreeNode node = new TreeNode(num[s]);
                p.right = node;
            }
            else if(e == s + 1){
                TreeNode node = new TreeNode(num[s]);
                p.right = node;
                doInsert(num, e, e, node, false);
            }
            else{
                int mid = (s + e)/2;
                TreeNode node = new TreeNode(num[mid]);
                p.right = node;
                doInsert(num, s, mid - 1, node, true);
                doInsert(num, mid + 1, e, node, false);
            }
        }
    }