# CompSci 261, Winter 2018, Homework 5

1. Suppose that a binary min-heap stores six elements with priorities 10, 20, 30, 40, 50, and 60 in its array $A$. What is the largest of these items that could be stored in $A[1]$? Draw the tree structure for a valid heap-ordered tree that places this item in $A[1]$, with each node of the tree labeled by the element it holds.

2. Draw the shape of the forest that you would get if you inserted nine elements into a Fibonacci heap and then performed a single delete-min operation. In your drawing, the children of each node should appear in left-to-right order in the order they were added as children (the first child on the left, etc).

3. In a hypercube network with $n$ vertices, the number of edges is $\tfrac{1}{2} n\log_2 n$. For instance, a cube network with $8$ vertices has $12 = \tfrac{1}{2} 8\log_2 8$ edges. Suppose that we are running Dijkstra's algorithm on such a network, using a $k$-ary heap for its priority queue. What should we choose as the value of $k$ in order to minimize the total time of Dijkstra's algorithm, and what is the total time of the algorithm for this choice? (Use $O$-notation for the time, simplified as much as possible. Your answer for the total time should only be a formula of $n$; it should not have $k$ as a separate variable in its formula.)

4. Suppose we create a binary search tree on the three elements 10, 20, and 30 by inserting the three elements one at a time, without rebalancing, in a randomly chosen order. That is, we choose randomly one of the six permutations of 10, 20, and 30, and then, for each element in order, place it into the tree as a child of one of the previously placed tree nodes without changing the structure of the previous nodes. What is the probability that the resulting binary search tree can be labeled with ranks to make it a valid WAVL tree?