Honor Code Acknowledgment: ___________________
If there are n levels in a complete tree (the tree on the left
above has two levels, the tree on the right has four) what is the total
number of nodes in the complete tree (both leaves and internal
nodes) and the total number of leaves in the complete tree.
Express answers in terms of n.
Problem 1: Big and Bushy (4 points)
In a complete binary tree, every non-leaf node has two
children, and all the leaves are at the same level. Two examples of
complete trees are shown below.
Problem 2: Q-tip (4 points)
Write a function to print the nodes of a binary tree in
level order, that is print all the nodes in one level,
left-to-right, before any nodes in a lower level are printed. The first
node printed is the root (at level 1), followed by its children (at
level 2), followed by the root's grandchildren (at level 3) etc.
You should use a queue in your function, put the root on the queue, then
repeatedly dequeue an element, print it, and put its children on the
queue. This function is NOT recursive.