Starting from:
$35

$29

Homework 9: Amortized Analysis and Fibonacci Heaps Solution

Problems

    1. (25 pts) Exercise 17.3-3.(Hint: a reasonable potential function to use is (Di) = kni ln ni where ni is the number of elements in the binary heap, and k is a big enough constant. You can use this function and just show the change in potential for each of the two operations.)

    2. (25 pts) Exercise 17.3-6.

    3. (25 pts) Exercise 19.2-1

    4. (50 pts). Implement binomial heaps as described in class and in the book. You should use links (pointers) to implement the structure as shown in the gure 1. Your implementation should include the operations: Make-heap, Insert, Minimum, Extract-Min, Union, Decrease-Key, Delete

































Figure 1: binomial heaps

Make sure to preserve the characteristics of binomial heaps at all times: (1) each component should be a binomial tree with children-keys bigger than the parent-key;

1

        (2) the binomial trees should be in order of size from left to right. Test your code several arrays set of random generated integers (keys).

    5. (Extra Credit) Find a way to nicely draw the binomial heap created from input, like in the gure.

    6. (Extra Credit). Write code to implement Fibonacci Heaps, with discussed operations: ExtractMin, Union, Consolidate, DecreseKey, Delete.

    7. (Extra Credit). Figure out what are the marked nodes on Fibonacci Heaps. In partic-ular explain how the potential function works for FIB-HEAP-EXTRACT-MEAN and FIB- HEAP-DECREASE-KEY operations.















































2

More products