Assignment 4: Heaps and priority queues

Date: 3-03-2017
Deadline:11-03-2017 23:59

Objectives

You must implement a heap and priority queue API and use them to write a waiting queue manager.

Requirements

You will construct a program queue that demonstrates your heap and priority queue API. The required behavior of the program is given in the following section.

It is strongly recommended to implement your heap structure as an array. We provide a dynamic array implementation in array.h and array.c. We advise you to use these array functions to implement your heap.

You must submit your work as a tarball [1]. Next to the source code, your archive must contain a text file file named “AUTHORS” containing your name and Student ID(s).

[1]http://lmgtfy.com/?q=how+to+make+a+tarball

Waiting queue

Your program will manage queuing at a Doctor's office which does not take appointments. The situation at this office is as follows:

To translate this into a program, you will work with the following:

A typical day of 10 hour long sessions in the doctors office is shown below. Carl, Bob, Albert and Barbara show up early and get treated by the doctor in alphabetical order. Jim, Tom and Zoe arrive late in the day, so Tom and Zoe leave without being treated:

Input Output

Carl 22

Bob 68

Albert 35

.

Albert

.

Barbara 40

.

Barbara

.

.

Bob

.

.

Carl

.

. .
. .
. .

Alice 28

.

Alice

.

. .

Jim 30

Tom 31

Zoe 29

.

Jim

.

 

Tom

Zoe

Getting started

  1. Unpack the provided source code archive; then run make.
  2. Try out the generated queue program and familiarize yourself with its interface.
  3. Read the files prioq.h and understand the interface.
  4. Implement the data structure in heap.c.
  5. Implement the missing code in main.c.

Grading

Your grade starts from 0, and the following tests determine your grade:

The following extra features will be tested to obtain higher grades, but only if you have obtained a minimum of 5 points on the list above already: