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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is the generalised greedy strategy?

A
  1. check if problem exhibits the optimal substructure property
  2. Develop a recursive solution
  3. show that with a greedy choice only one sub-instance remains
  4. show that the greedy choice is ‘safe’ (exchange argument)
  5. Design a recursive greedy algorithm
  6. Convert to an iterative algorithm
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly