public ArrayList<T> levelOrdertoArray(LinkedBinaryTree<T> t) {
        ArrayList<T> list;
        list = new ArrayList<>();
        int height=t.height();
        for(int i=0;i<Math.pow(2, height)-2;i++){
            list.add(null);
        }
        int i = 0;
        ArrayQueue<BinaryTreeNode<T>> q = new ArrayQueue<>();
        BinaryTreeNode<T> tt = t.root;
        list.add(0,t.root.element);
        while (tt != null) {
            if(list.get(i)!=null){
            // put t's children on queue
            if (tt.leftChild != null) {
                q.put(tt.leftChild);
                 list.set(2 * i + 1, tt.leftChild.element);
            }
          
           
            if (tt.rightChild != null) {
                q.put(tt.rightChild);
                list.set(2 * i + 2, tt.rightChild.element);
            }
            

            
            // get next node to visit
            tt = (BinaryTreeNode<T>) q.remove();
            }
            i++;
        }
        return list;
    }