Assignment 4: Greedy
Overview
The goal of this assignment is to familiarize students with Greedy algorithms.
• Design greedy strategies (not just apply them)
• Justify why a greedy choice might work
• Identify and explain failure cases
• Develop step-by-step reasoning (interview skill)
Rules and Deliverables
•
•
•
•
•
This is an individual assignment.
Cheating of any kind is NOT tolerated! Assignments will be checked against each other,
and illegal collaboration will be treated based on the University dishonesty policy.
The due date will be Sunday 4/19/2026 at 11:59pm.
Submitting the assignment 24 hours after the due date will result in a deduction
of 20% from the student's grade.
Each student should submit the answers document in only one PDF format file through
Canvas.
Assignment Description
You are given a list of file sizes. You must merge them into a single file with minimum total cost.
Each merge:
•
Combines two files
•
Cost = sum of their sizes
Task 1 – Propose Two Greedy Strategies
You must propose two different greedy strategies.
For each strategy:
1. Clearly define the rule (e.g., what choice do you make at each step?)
2. Explain why you think it might lead to a low cost (2–3 sentences)
Task 2 – Define Your Own Input and Execute Both Strategies
You must create your own input.
Write your input clearly:
•
files = [ … ]
•
Do not use trivial inputs (e.g., [1,2,3,4])
Apply both of your proposed strategies step by step on your input.
For each strategy, complete the table:
Step Files After Merge Cost of Merge Total Cost
1
2
…
Final Answer: Total Cost = ______
Rules:
•
You must recompute choices at each step
•
After merging, replace the two files with the new file
•
Order does not matter, but the set must be correct
Task 3 – Compare Your Strategies
Strategy Total Cost
Strategy 1
Strategy 2
Which strategy performs better and why?
(2–4 sentences, must reference your results—not generic statements)
Task 4 – Critical Reflection
One of your strategies should perform worse.
Explain:
•
Why does it fail?
•
What specific decision causes higher cost?
Be precise. Vague answers get no credit.
Grading Rubric
Task
Points What is evaluated
Strategy design
10
clarity + reasoning quality
Execution (both) 10
correctness of steps
Comparison
20
correct + justified
Reflection
20
depth of insight