CSC 421: Algorithm Design & Analysis
Fall 2024

HW4: Greedy Scheduling


Consider the challenge of constructing a daily schedule given a (potentially large) set of event options. For example, a student planning his or her day might choose from the following possible events:

 
 0:00   7:30      Sleep
 0:00  10:20      Sleep in
 7:45   8:00      Shower
 8:00   8:45      Breakfast with friends
 8:10   8:40      Social Media
 8:50  10:30      Study for class
11:00  12:15  REQ CSC 421
12:30  13:45      Lunch
12:30  13:30      Exercise 
13:30  13:50      Power nap
14:00  15:45  REQ GDE 324
15:15  15:25      Call parents
15:30  17:00      Social Media
16:15  16:25      Call parents

Two events are in conflict if their time intervals overlap. For example, Lunch (12:30-13:45) overlaps with Power nap (13;30-13:50), so can't both be in the same schedule. You may assume that events are at least one minute long, so two events that begin at the same time must be in conflict, e.g., Lunch and Exercise. However if an event starts at the same time another ends, then the two are not in conflict, e.g., Exercise and Power nap. Events that are required are preceded with "REQ" and must be included in any schedule. You may assume that required events cannot be in conflict with each other.

You are to implement four different greedy approaches for constructing a schedule:

Your program should read in a text file, with each line specifying the start and end times (in military notation) and a description of a single event. For example, see events.txt. Your program should display the four schedules generated using the above greedy strategies. Each schedule should list the selected events in chronological order (one event per line) and should clearly identify the approach used. The "REQ" designation should NOT appear when displaying required events and times should be properly aligned. For example:

Shortest event first: --------------------- 0:00 7:30 Sleep 7:45 8:00 Shower 8:10 8:40 Social Media ... Longest event first: -------------------- 0:00 10:20 Sleep in 11:00 12:15 CSC 421 12:30 13:45 Lunch ... Earliest start-time first: ------------------------- 0:00 7:30 Sleep 7:45 8:00 Shower 8:00 8:45 Breakfast with friends ... Earliest end-time first: ----------------------- 0:00 7:30 Sleep 7:45 8:00 Shower 8:10 8:40 Social Media ...

You should follow sound object-oriented practices in designing and implementing the project, defining highly-cohesive and loosely-coupled classes as needed. Likewise, avoid duplicate and redundant code wherever possible.

Hint: To avoid duplication, you might want to consider implementing Comparators for the different scheduling strategies.