How to draw the heap for an array in Java? I have an assignment to draw the heap after an ArrayList and a LinkedList is created.
public static void main(String[] args) {
     List list = new ArrayList();
     list.add(0);
     list.add(1);
     list.add(1);
     list.add(2);
}

and
public static void main(String[] args) {
     List list = new LinkedList();
    list.add(0);
     list.add(1);
     list.add(1);
     list.add(2);
}

So far I have a tree set up for [0, 1, 1, 2] so that it just goes down like a tree from 0, 1 and 1, then 2. But I don't know if that's correct and if it'd be different for the ArrayList and LinkedList.
Heap is an almost complete binary tree. So if you're planning to construct the tree you can just start by filling the values in the tree from top to down and left to right ie, proceed by filling nodes levelwise.
Arraylist or linked list doesn't matter here because both stored the level order traversal of the tree.
Ex. list.add(0), list.add(1), list.add(1), list.add(2), list.add(3), list.add(5)
                              0
                            /    \
                           1      1
                           / \     /
                         2   3  5