Assignment 11 -- Due Tuesday, November 20 (at the beginning of lab)
CS 4521 Fall Semester, 2012
20 Points

Topic: Implementation of Fibonacci Heaps

The assignment consists of two parts:
Part 1: (15 points) Implementation of Fibonacci Heaps.
Part 2: (5 points) Fibonacci Heap exercises.
For Part 2, write code and that implements Fibonacci heap operations as described in Chapter 19 of the text. Implementing Fibonacci heaps will require coding the operations:

• MAKE-FIB-HEAP (a constructor in C++)
• FIB-HEAP-INSERT
• FIB-HEAP-MINIMUM
• FIB-HEAP-EXTRACT-MIN
• FIB-HEAP-UNION (not required - extra credit)
Much of the code is provided for you. You need to supply code for FIB-HEAP-EXTRACT-MIN - consolidate() in particular.

You can use a modified version of the command interpreter for binary heaps (in Assignment 4); as in that assignment, i, m, and e insert, return the minimum key value, and extract the minimum. Also, a routine to show the structure of your Fibonacci heap is supplied for you.

#### Test Example

The test files are the same as for binary heaps. The correct output for heaptest1 is at: out1.txt.

Helpful code: Here is a .h file for the Fibonacci Heap (FibHeap) class fibheap.h. and skeleton code for the BHeap class implementation fibheap.cpp. Here is a command interpreter: cmdint.cpp. Here is a "Makefile" that puts it all together: Makefile. When you download these files, be sure to remove the ".txt" suffixes (by moving them to the same file name without the ".txt").

#### What To Hand In

Hand in a copy of your code and the output of the test files (15 points): Identify them clearly and draw in the links between nodes printed by the ShowHeap() operation.

Also hand in the following:

• Exercise 19.2-1 (4 points), page 518.
• Read Problem 19-2 pages 527-529, then write a statement saying "I have read Problem 19-2." on the homework you turn in (1 point).

### Extra Credit (up to 6 points)

Implement the union, decrease-key, and delete operations, and test them with test files that show those operations work correctly. To do this, you should also implement a search(k) operation that returns a pointer, x, to the node with key k. Then to test decrease-key in your command interpreter, first search for the original key value k-orig with search(k-orig) to get x, then call decrease-key(x, k-new) where k-new is the decreased value of the key. Similarly, to test delete for a node with key value k, first search(k) to get x, and then call delete(x).

Page URL: http://www.d.umn.edu /~ddunham/cs4521f12/assignments/a11/assignment.html
Page Author: Doug Dunham