0% found this document useful (0 votes)
9 views2 pages

Assignment4 Fall 24 25

Uploaded by

aboalzayde
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views2 pages

Assignment4 Fall 24 25

Uploaded by

aboalzayde
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Yarmouk University

Faculty of Information Technology and Computer Science


Department of Computer Sciences
Fall Semester 2024/2025
CS352 Problem-Solving Assignment4: Greedy Algorithm
Instructor: Dr. Noor Aldeen Alawad, Email: [email protected]
18/11/2024 Midnight is the deadline of this Assignment

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: Activity Selection Using Greedy Algorithm


Imagine you have a list of activities, each with a start and end time. Your task is to select the
maximum number of activities that can be attended without any overlap. Use a Greedy
Algorithm approach to find the optimal solution.

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.

Input: List of activities with start and end times.


Output: Maximum number of activities that can be attended, along with the chosen
activities.

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.

Performance and Complexity Analysis

Analyze the time complexity of the greedy approach and discuss why this is more efficient
than a brute-force solution.

Submission and Requirements:


1. Code:
- Implement the solution in a programming language of your choice.
- Your program should output the maximum number of activities and the list of selected
activities.
2. Report:
- Submit a short report (1-2 pages) explaining:
- The Greedy strategy you applied.
- Why the greedy approach optimally solves the problem.
- Analysis of time complexity.

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?

You might also like