2010 November 3 / |j|d|a|v|i|s|@|c|a|r|l|e|t|o|n|.|e|d|u

Assignment: Heaps

Carleton College CS 201, Prof. Joshua R. Davis

Introduction

The goal of this assignment is to implement a priority queue using a binary heap. This topic is covered in your textbook. In fact, the textbook provides code to implement the whole thing. However, our priority queue differs from the book's in several ways:

So while you could copy a lot of code out of the textbook and adjust the code to your needs, it might be less frustrating, and it will certainly be more educational, to write all of the code yourself.

You will complete this assignment with an assigned partner. It is due Sunday at 11:59 PM.

Implement PriorityQueue

On the course web site, download the file priorityqueue_avltn.py. Rename it to priorityqueue_heap.py; this is the file you'll be editing and handing in.

You need to change the docstring for the PriorityQueue class. The AVL tree implementation handles equal priorities in a FIFO manner, but our heap implementation will not. Change the docstring to reflect this. What does this mean for our users? The users should not assume that all implementations of PriorityQueue break ties FIFO; some do, and some don't. We're very forthright about this issue, so the users can't complain.

Now rewrite all of the methods of PriorityQueue. Do not change any docstrings; the methods should work exactly as they do in the AVL tree PriorityQueue (with the exception of the FIFO behavior). I have some specific requirements.

Submit Your Work

Submit your file priorityqueue_heap.py electronically as usual. It will be graded according to these criteria: