Activity Selection Problem DP
Activity Selection Problem DP
Algorithm
Muhammad Umer Mehmood
Activity Selection Problem
Output:
{1,4}, {5,7}, {8,11}, {12,14}
In Previous Lecture (Greedy
Algorithm)
• We discussed the greedy approach to the activity selection problem.
• {0,6}, {1,4}, {2,13}, {3,5}, {3,8}, {5,7}, {5,9}, {6,10}, {8,11}, {8,12},
{12,14},
Example
would be:
Time Complexity
• The time complexity of the above solution is and require extra space,
where n is the total number of given activities.
i 1 2 3 4 5 6 7 8 9 10 11
1 3 0 5 3 5 6 8 8 2 12
4 5 6 7 9 9 10 11 12 14 16