8.1 Greedy Algorithms Flashcards
(4 cards)
1
Q
What is the runtime complexity for the greedy recursive algorithm and why
A
theta(n). as the runtime is dominated by incrementing m. It can never go > n and then recursions don’t restart m.
2
Q
What is the runtime complexity for the greedy iterative algorithm and why is it better than recursive
A
theta(n). simpler to understand. don’t need to save each stack frame to memory.
3
Q
What is the generalised greedy strategy?
A
- check if problem exhibits the optimal substructure property
- Develop a recursive solution
- show that with a greedy choice only one sub-instance remains
- show that the greedy choice is ‘safe’ (exchange argument)
- Design a recursive greedy algorithm
- Convert to an iterative algorithm
4
Q
A