Daniel Sutantyo, Department of Computing, Macquarie University
5.1 - Greedy Algorithm
Non examples (i.e. problems you cannot solve using greedy algorithm)
5.1 - Greedy Algorithm
5.1 - Greedy Algorithm
10
15
3
A
F
C
D
3
14
5.1 - Greedy Algorithm
5.1 - Greedy Algorithm
5.1 - Greedy Algorithm
5.1 - Greedy Algorithm
5.1 - Greedy Algorithm
5.1 - Greedy Algorithm
5.1 - Greedy Algorithm
5.1 - Greedy Algorithm
5.1 - Greedy Algorithm
5.1 - Greedy Algorithm
\[\text{minR}(n) = \begin{cases}\displaystyle\min_{i\ :\ b_i\le n}\left(1 +\text{minR}(n-b_i)\right) & \text{if $n > 0$}\\ \quad \quad \quad\quad 0 & \text{otherwise}\end{cases}\]
5.1 - Greedy Algorithm
5.1 - Greedy Algorithm
5.1 - Greedy Algorithm
4
7
4
5
1
3
5
2
3
2
4
5.1 - Greedy Algorithm
4
7
4
5
1
3
5
2
3
2
4
5.1 - Greedy Algorithm
4
7
4
5
1
3
5
2
3
2
4
5.1 - Greedy Algorithm
4
7
4
5
1
3
5
2
3
2
4
5.1 - Greedy Algorithm
4
7
4
5
1
3
5
2
3
2
4
5.1 - Greedy Algorithm
4
7
4
5
1
3
5
2
3
2
4
5.1 - Greedy Algorithm
4
7
4
5
1
3
5
2
3
2
4
5.1 - Greedy Algorithm
4
1
3
2
3
2
5.1 - Greedy Algorithm
5.1 - Greedy Algorithm
5.1 - Greedy Algorithm
10
3
5.1 - Greedy Algorithm
10
3
???
5.1 - Greedy Algorithm
3
???
5.1 - Greedy Algorithm
3
???
5.1 - Greedy Algorithm
\[\text{minC}(n) = \begin{cases}\displaystyle\min_{i\ :\ b_i\le n}\left(1 +\text{minC}(n-c_i)\right) & \text{if $n > 0$}\\ \quad \quad \quad\quad 0 & \text{otherwise}\end{cases}\]
\(C = \{c_1,c_2,c_3,c_4\} =\{1,25,50,100\}\)
\(1+\text{minC}(n-100)\)
\(1+\text{minC}(n-50)\)
\(1+\text{minC}(n-25)\)
\(1+\text{minC}(n-1)\)
\(\text{minC}(n)\)
5.1 - Greedy Algorithm
5.1 - Greedy Algorithm
(by the way, I'm not going to prove optimal substructure here, because it's just the same cut-and-paste argument again)
5.1 - Greedy Algorithm
\(C = \{c_1,c_2,c_3,c_4\} =\{1, 7, 10, 20\}\)
5.1 - Greedy Algorithm
\(C = \{c_1,c_2,c_3,c_4\} =\{1, 7, 10, 20\}\)
5.1 - Greedy Algorithm