Computer Science 210 Lab 8: Scheduling Revisited
Due: November 23rd, 1999

Objectives and Overview: In this lab we'll return to the Scheduling data structure you developed for Lab 6, extend it and start to examine how it might be used in performing scheduling.

Part 1 - Extend the StringList Class

Within the StringList class you developed in Lab 6 each Node in a given list contained a pointer to the next Node as well as a value corresponding to the name of a student.  In the updated program your Node will contain additional information corresponding to a priority given by the student for that particular time slot.

The priority can be obtained from the order in which the time slots are listed in the file.  For this lab a new schedule file called "schedule2" has been placed in the course folder. For example, if the file contained the following line:

Eric 8 4 10 3

It can be interpreted as meaning that my first preference is time slot 8, my second is for time slot 4, etc.

Your first step should be to rewrite your old program to include this information.  Be sure to update display() such that it now displays priority information.  Your second step should be to further update your old program such that the insert routine inserts by priority rather than simply at the front or end of the list.  That is to say that the list should be maintained in such a way that all of the students who have the time slot as their first priority are at the start of the list, followed by all of the students for whom the time slot is the second priority, etc.
 

Part 2 - Implement a Rudimentary Scheduling Algorithm

A simple scheduling program might proceed as follows:

    for each level of priority
        for each time slot
            if only one student has the time slot at the current level of priority
                then  {
                    the student is given the time slot - an appropriate message is printed
                    the time slot is removed from future consideration
                    all occurences of the student are removed from other time slots
                }
                else all students with the current priority are removed from this time slot

To implement this algorithm you will need some more functions in your StringList class - delete(String s, int slot) - which should search for a Node with the appropriate value and delete it from the timeslot.  A function howmany(int slot, int n) which returns the number of strings at priority level n will also be useful.  Implement the algorithm and run it on the "schedules2" file. With such a function, another version of delete - delete(int slot, int n)  which deletes the first n elements of the timeslot - might also be useful. While you are debugging the program, I highly reccommend you make liberal use of your display functions. E.g. when you are debugging the new delete function, immediately display the list to ensure that the delete worked properly.
 

Now answer the following questions
  1. Will the algorithm always work?  That is, will it always produce a schedule with a time slot for every student?  Justify your answer.
  2. Provide an example to show that the algorithm is not "fair" (under what circumstances might a student complain?).  Suggest an improvement to make the algorithm more fair.
  3. Analyze the complexity of the algorithm in terms of N (number of students), P (number of levels of priority possible) and T (number of time slots).  Your analysis should be in terms of the best upper bound (in other words use Big O notation, but find the smallest Big O you can).
 

Lab 8 Deliverables:

Submit to the Drop Box your code for Parts 1 and 2. Don't forget I want your entire lab folder for the project.

Also, hand in hardcopy listings of these program files with your name on them and a hardcopy version of your program's output on the schedule2 file. Your program should contain sufficient commentary documentation for me to understand its overall design and logic.  Include with this, your answers to the questions in Part 2.