Assignment4 Fall 24 25
Assignment4 Fall 24 25
Assignment Overview:
In this assignment, you will work individually to apply Greedy Algorithm techniques to
solve the Activity Selection Problem. This problem is common in scheduling and requires
you to maximize the number of activities that can be completed without conflicts.
Problem definition:
You are given a list of activities, each defined by its start and end time. For example, given
activities with start and end times as follows:
- Activity 1: (1, 3)
- Activity 2: (2, 5)
- Activity 3: (4, 6)
- Activity 4: (6, 8)
Find the maximum number of non-overlapping activities that can be selected.
Greedy Approach
1. Define the criteria: Sort the activities by their end times.
2. Selection Strategy: Always select the activity that finishes the earliest and does not
overlap with previously selected activities.
3. Iteration and Selection: Loop through sorted activities, adding them to the selected list if
they do not overlap with the last selected activity.
Testing and Edge Cases
- Test with different numbers of activities, including cases with overlapping and non-
overlapping intervals.
- Consider edge cases, such as:
- Only one activity.
- All activities overlap with each other.
- Activities with identical start and end times.
Analyze the time complexity of the greedy approach and discuss why this is more efficient
than a brute-force solution.
Submission Guidelines:
1. Code: Submit clean, modular, well-commented code.
2. Write-up: Each student should submit a report clearly explaining their solution and
approach.
Zip File Naming Convention: Use a4_studentID.zip, where studentID is your ID.
Submission Portal: Course Moodle (Yarmouk E-learning site) under Assignment #4.
Incorrect submissions will not be accepted for re-evaluation.
Grading Scheme
1. Correctness (20%): Does the solution find the maximum number of activities?
2. Efficiency (15%): Is the greedy approach efficiently implemented?
3. Code Quality (15%): Is the code clean, modular, and well-documented?
4. Write-up and Presentation (50%): Does the report clearly explain the approach,
complexity, and advantages?