public void printZigZag(BSTNode<T> root) {

        LinkedList<Pair> nextLevelStack = new LinkedList<>(); // this keeps odd level nodes
        LinkedList<Pair> currentLevelStack = new LinkedList<>(); // this keeps even level nodes

        //add the root to even level stack
        currentLevelStack.addFirst(new Pair(root, 0));

        int printLevel = 0;
        // iterate while both are not empty
        while(!currentLevelStack.isEmpty() || !nextLevelStack.isEmpty() ) {
             // for even printLevel
            if(printLevel %2 ==0) {
                // pop even level stack
                Pair p  = currentLevelStack.removeFirst();
                // print the data without new line
                System.out.print(" "+ p.node.data+ " ");
                //push left child to nextLevel(odd level) stack if it is present
                if(p.node.left != null) {
                    nextLevelStack.addFirst(new Pair(p.node.left,p.level+1));
                }
                //push right child to nextLevel(odd level) stack if it is present
                if(p.node.right != null) {
                    nextLevelStack.addFirst(new Pair(p.node.right,p.level+1));
                }
                // check if evenLevel stack is empty .. if yes increment the print level
                if(currentLevelStack.isEmpty()){
                    printLevel ++;
                    // this is for printing level by level in new line
                    System.out.println();
                }

            } else {

                Pair p  = nextLevelStack.removeFirst();

                System.out.print(" "+p.node.data+" ");
                if(p.node.right != null) {
                    currentLevelStack.addFirst(new Pair(p.node.right,p.level+1));
                }
                if(p.node.left != null) {
                    currentLevelStack.addFirst(new Pair(p.node.left,p.level+1));
                }

                if(nextLevelStack.isEmpty()){
                    printLevel ++;
                    System.out.println();
                }

            }
        }

    }