[Verse 1]
Got a list of tasks with start and finish times
Need to pick the max without conflicts in lines
Greedy algorithm coming through with the flow
Sort by finish first, that's the way to go
Activity selection, optimization game
Choose the most you can, no overlap shame
Each task has a window, beginning to end
Smart choices matter when resources we spend
[Chorus]
Sort by finish, pick the earliest end
Greedy choice, let the algorithm blend
No overlap, keep the schedule clean
Maximum activities in the time machine
Sort by finish, pick the earliest end
Greedy choice, let the algorithm blend
Activity selection, the optimal way
Pack the most into your busy day
[Verse 2]
Start with first activity when finish time's least
Then scan through the list, find the next feast
Compatible means start time comes after
Previous finish, no scheduling disaster
Linear scan through the sorted array
Each valid choice leads the optimal way
Proof by contradiction shows it's the best
Greedy stays ahead, outperforms the rest
[Chorus]
Sort by finish, pick the earliest end
Greedy choice, let the algorithm blend
No overlap, keep the schedule clean
Maximum activities in the time machine
Sort by finish, pick the earliest end
Greedy choice, let the algorithm blend
Activity selection, the optimal way
Pack the most into your busy day
[Bridge]
Exchange argument proves the method right
If another solution seems just as bright
We can swap activities one by one
Our greedy choice gets the same result done
O of n log n for the sorting phase
O of n for selection in the maze
Optimal substructure, greedy choice too
Dynamic programming alternative view
[Verse 3]
Interval scheduling, meeting rooms to book
Conference planning, take a deeper look
Resource allocation in the real world scene
Activity selection keeps the schedule lean
Recursive solution builds from the ground
But greedy iteration is more profound
Bottom-up thinking with the optimal play
Maximum value in minimum time today
[Chorus]
Sort by finish, pick the earliest end
Greedy choice, let the algorithm blend
No overlap, keep the schedule clean
Maximum activities in the time machine
Sort by finish, pick the earliest end
Greedy choice, let the algorithm blend
Activity selection, the optimal way
Pack the most into your busy day
[Outro]
When intervals conflict and choices arise
Sort by finish, that's the compromise
Greedy algorithms, they lead the way
Activity selection saves the day