CS14 SPRING 2001
WRITTEN ASSIGNMENT 4
Assigned: May 25, 2001
Due: June 3, 2001
// read all the data into an array H
for (int i = n/2; i > 0; i--)
heapify (H, i); // heapify the subheap rooted at i.
A level-order traversal of a tree prints out the nodes of the tree by row, and within each row from left to right. In a heap, which is a complete binary tree stored in an array, this is easily accomplished by printing out the contents of cells 1…2 of the array.
Describe a scheme for performing a level-order traversal of a general binary tree (not necessarily complete, stored as treenodes with left & right pointers).