6.17 - Dynamic programming - Exact Changerpeng/CS3510_F17/Notes/Oct16... · 2017. 10. 16. · 6.17...
Transcript of 6.17 - Dynamic programming - Exact Changerpeng/CS3510_F17/Notes/Oct16... · 2017. 10. 16. · 6.17...
![Page 1: 6.17 - Dynamic programming - Exact Changerpeng/CS3510_F17/Notes/Oct16... · 2017. 10. 16. · 6.17 - Dynamic programming - Exact Change Running Time I No. of subproblems: O(v) I Transition](https://reader033.fdocuments.in/reader033/viewer/2022051803/5febecf0a2fcc0722a270b40/html5/thumbnails/1.jpg)
6.17 - Dynamic programming - Exact Change
I Coins X := {x1, · · · , xn}I Total value needed: v .
I We want: Can we make change of v using the coins given?
![Page 2: 6.17 - Dynamic programming - Exact Changerpeng/CS3510_F17/Notes/Oct16... · 2017. 10. 16. · 6.17 - Dynamic programming - Exact Change Running Time I No. of subproblems: O(v) I Transition](https://reader033.fdocuments.in/reader033/viewer/2022051803/5febecf0a2fcc0722a270b40/html5/thumbnails/2.jpg)
6.17 - Dynamic programming - Exact Change
Subproblem?
I C (w); 1 ≤ w ≤ v
I C (w) = 1 if we CAN make change for w . 0 otherwise.
I We want to compute: C (v)
I Base case: C (0) = 1
I Recursion: Idea: choices of first coin used
C (w) = maxxi∈coin set
C (w − xi )
![Page 3: 6.17 - Dynamic programming - Exact Changerpeng/CS3510_F17/Notes/Oct16... · 2017. 10. 16. · 6.17 - Dynamic programming - Exact Change Running Time I No. of subproblems: O(v) I Transition](https://reader033.fdocuments.in/reader033/viewer/2022051803/5febecf0a2fcc0722a270b40/html5/thumbnails/3.jpg)
6.17 - Dynamic programming - Exact Change
Running Time
I No. of subproblems: O(v)
I Transition Time: O(n) time
I So, total running time O(vn)
![Page 4: 6.17 - Dynamic programming - Exact Changerpeng/CS3510_F17/Notes/Oct16... · 2017. 10. 16. · 6.17 - Dynamic programming - Exact Change Running Time I No. of subproblems: O(v) I Transition](https://reader033.fdocuments.in/reader033/viewer/2022051803/5febecf0a2fcc0722a270b40/html5/thumbnails/4.jpg)
6.16 - Dynamic programming - Garage Sale
I Garage sales G := {g1, · · · , gn}I Cost of traveling from garage gi to gj is dijI Profit earned at garage gi is pi .
I We want: Most profitable route from home (g0) and back.
![Page 5: 6.17 - Dynamic programming - Exact Changerpeng/CS3510_F17/Notes/Oct16... · 2017. 10. 16. · 6.17 - Dynamic programming - Exact Change Running Time I No. of subproblems: O(v) I Transition](https://reader033.fdocuments.in/reader033/viewer/2022051803/5febecf0a2fcc0722a270b40/html5/thumbnails/5.jpg)
6.16 - Dynamic programming - Garage Sale
Subproblem?
I C (S , j); S ⊆ G , gj ∈ S
I C (S , j) is the max profit earned starting at home, ending at gjand only being allowed to use the garages in S .
I We want to compute: maxgi∈G C (G , j) + dj0I Base case: C ({gj}, j) = pj − d0jI Recursion: Idea: choices of garage visited just before gj
C (S , j) = maxgi∈S :i 6=j
{C (S − {gj}, i) + pj − dij}
![Page 6: 6.17 - Dynamic programming - Exact Changerpeng/CS3510_F17/Notes/Oct16... · 2017. 10. 16. · 6.17 - Dynamic programming - Exact Change Running Time I No. of subproblems: O(v) I Transition](https://reader033.fdocuments.in/reader033/viewer/2022051803/5febecf0a2fcc0722a270b40/html5/thumbnails/6.jpg)
6.16 - Dynamic programming - Garage Sale
Running Time
I No. of subproblems: O(n) · O(2n)
I Transition Time: O(n) time
I So, total running time O(n22n).
![Page 7: 6.17 - Dynamic programming - Exact Changerpeng/CS3510_F17/Notes/Oct16... · 2017. 10. 16. · 6.17 - Dynamic programming - Exact Change Running Time I No. of subproblems: O(v) I Transition](https://reader033.fdocuments.in/reader033/viewer/2022051803/5febecf0a2fcc0722a270b40/html5/thumbnails/7.jpg)
4.1 - Bellman Ford example 1.
IterationNode 0 1 2 3 4 5 6 7
A 0B ∞C ∞D ∞E ∞F ∞G ∞H ∞
![Page 8: 6.17 - Dynamic programming - Exact Changerpeng/CS3510_F17/Notes/Oct16... · 2017. 10. 16. · 6.17 - Dynamic programming - Exact Change Running Time I No. of subproblems: O(v) I Transition](https://reader033.fdocuments.in/reader033/viewer/2022051803/5febecf0a2fcc0722a270b40/html5/thumbnails/8.jpg)
4.1 - Bellman Ford example 1.
IterationNode 0 1 2 3 4 5 6 7
A 0 0B ∞ 1C ∞ ∞D ∞ ∞E ∞ 4F ∞ 8G ∞ ∞H ∞ ∞
![Page 9: 6.17 - Dynamic programming - Exact Changerpeng/CS3510_F17/Notes/Oct16... · 2017. 10. 16. · 6.17 - Dynamic programming - Exact Change Running Time I No. of subproblems: O(v) I Transition](https://reader033.fdocuments.in/reader033/viewer/2022051803/5febecf0a2fcc0722a270b40/html5/thumbnails/9.jpg)
4.1 - Bellman Ford example 1.
IterationNode 0 1 2 3 4 5 6 7
A 0 0 0B ∞ 1 1C ∞ ∞ 3D ∞ ∞ ∞E ∞ 4 4F ∞ 8 7G ∞ ∞ 7H ∞ ∞ ∞
![Page 10: 6.17 - Dynamic programming - Exact Changerpeng/CS3510_F17/Notes/Oct16... · 2017. 10. 16. · 6.17 - Dynamic programming - Exact Change Running Time I No. of subproblems: O(v) I Transition](https://reader033.fdocuments.in/reader033/viewer/2022051803/5febecf0a2fcc0722a270b40/html5/thumbnails/10.jpg)
4.1 - Bellman Ford example 1.
IterationNode 0 1 2 3 4 5 6 7
A 0 0 0 0B ∞ 1 1 1C ∞ ∞ 3 3D ∞ ∞ ∞ 4E ∞ 4 4 4F ∞ 8 7 7G ∞ ∞ 7 5H ∞ ∞ ∞ ∞
![Page 11: 6.17 - Dynamic programming - Exact Changerpeng/CS3510_F17/Notes/Oct16... · 2017. 10. 16. · 6.17 - Dynamic programming - Exact Change Running Time I No. of subproblems: O(v) I Transition](https://reader033.fdocuments.in/reader033/viewer/2022051803/5febecf0a2fcc0722a270b40/html5/thumbnails/11.jpg)
4.1 - Bellman Ford example 1.
IterationNode 0 1 2 3 4 5 6 7
A 0 0 0 0 0B ∞ 1 1 1 1C ∞ ∞ 3 3 3D ∞ ∞ ∞ 4 4E ∞ 4 4 4 4F ∞ 8 7 7 7G ∞ ∞ 7 5 5H ∞ ∞ ∞ ∞ 8
![Page 12: 6.17 - Dynamic programming - Exact Changerpeng/CS3510_F17/Notes/Oct16... · 2017. 10. 16. · 6.17 - Dynamic programming - Exact Change Running Time I No. of subproblems: O(v) I Transition](https://reader033.fdocuments.in/reader033/viewer/2022051803/5febecf0a2fcc0722a270b40/html5/thumbnails/12.jpg)
4.1 - Bellman Ford example 1.
IterationNode 0 1 2 3 4 5 6 7
A 0 0 0 0 0 0B ∞ 1 1 1 1 1C ∞ ∞ 3 3 3 3D ∞ ∞ ∞ 4 4 4E ∞ 4 4 4 4 4F ∞ 8 7 7 7 7G ∞ ∞ 7 5 5 5H ∞ ∞ ∞ ∞ 8 8
![Page 13: 6.17 - Dynamic programming - Exact Changerpeng/CS3510_F17/Notes/Oct16... · 2017. 10. 16. · 6.17 - Dynamic programming - Exact Change Running Time I No. of subproblems: O(v) I Transition](https://reader033.fdocuments.in/reader033/viewer/2022051803/5febecf0a2fcc0722a270b40/html5/thumbnails/13.jpg)
4.1 - Bellman Ford example 1.
IterationNode 0 1 2 3 4 5 6 7
A 0 0 0 0 0 0 0B ∞ 1 1 1 1 1 1C ∞ ∞ 3 3 3 3 3D ∞ ∞ ∞ 4 4 4 4E ∞ 4 4 4 4 4 4F ∞ 8 7 7 7 7 6G ∞ ∞ 7 5 5 5 5H ∞ ∞ ∞ ∞ 8 8 6
![Page 14: 6.17 - Dynamic programming - Exact Changerpeng/CS3510_F17/Notes/Oct16... · 2017. 10. 16. · 6.17 - Dynamic programming - Exact Change Running Time I No. of subproblems: O(v) I Transition](https://reader033.fdocuments.in/reader033/viewer/2022051803/5febecf0a2fcc0722a270b40/html5/thumbnails/14.jpg)
4.1 - Bellman Ford example 1.
IterationNode 0 1 2 3 4 5 6 7
A 0 0 0 0 0 0 0 0B ∞ 1 1 1 1 1 1 1C ∞ ∞ 3 3 3 3 3 3D ∞ ∞ ∞ 4 4 4 4 4E ∞ 4 4 4 4 4 4 4F ∞ 8 7 7 7 7 6 6G ∞ ∞ 7 5 5 5 5 5H ∞ ∞ ∞ ∞ 8 8 6 6
![Page 15: 6.17 - Dynamic programming - Exact Changerpeng/CS3510_F17/Notes/Oct16... · 2017. 10. 16. · 6.17 - Dynamic programming - Exact Change Running Time I No. of subproblems: O(v) I Transition](https://reader033.fdocuments.in/reader033/viewer/2022051803/5febecf0a2fcc0722a270b40/html5/thumbnails/15.jpg)
4.1 - Bellman Ford example 1.
Shortest path tree:
![Page 16: 6.17 - Dynamic programming - Exact Changerpeng/CS3510_F17/Notes/Oct16... · 2017. 10. 16. · 6.17 - Dynamic programming - Exact Change Running Time I No. of subproblems: O(v) I Transition](https://reader033.fdocuments.in/reader033/viewer/2022051803/5febecf0a2fcc0722a270b40/html5/thumbnails/16.jpg)
4.2 - BF e.g. 2
IterationNode 0 1 2 3 4 5 6
S 0A ∞B ∞C ∞D ∞E ∞F ∞G ∞H ∞I ∞
![Page 17: 6.17 - Dynamic programming - Exact Changerpeng/CS3510_F17/Notes/Oct16... · 2017. 10. 16. · 6.17 - Dynamic programming - Exact Change Running Time I No. of subproblems: O(v) I Transition](https://reader033.fdocuments.in/reader033/viewer/2022051803/5febecf0a2fcc0722a270b40/html5/thumbnails/17.jpg)
4.2 - BF e.g. 2
IterationNode 0 1 2 3 4 5 6
S 0 0A ∞ 7B ∞ ∞C ∞ 6D ∞ ∞E ∞ 6F ∞ 5G ∞ ∞H ∞ ∞I ∞ ∞
![Page 18: 6.17 - Dynamic programming - Exact Changerpeng/CS3510_F17/Notes/Oct16... · 2017. 10. 16. · 6.17 - Dynamic programming - Exact Change Running Time I No. of subproblems: O(v) I Transition](https://reader033.fdocuments.in/reader033/viewer/2022051803/5febecf0a2fcc0722a270b40/html5/thumbnails/18.jpg)
4.2 - BF e.g. 2
IterationNode 0 1 2 3 4 5 6
S 0 0 0A ∞ 7 7B ∞ ∞ 11C ∞ 6 5D ∞ ∞ 8E ∞ 6 6F ∞ 5 4G ∞ ∞ ∞H ∞ ∞ 9I ∞ ∞ ∞
![Page 19: 6.17 - Dynamic programming - Exact Changerpeng/CS3510_F17/Notes/Oct16... · 2017. 10. 16. · 6.17 - Dynamic programming - Exact Change Running Time I No. of subproblems: O(v) I Transition](https://reader033.fdocuments.in/reader033/viewer/2022051803/5febecf0a2fcc0722a270b40/html5/thumbnails/19.jpg)
4.2 - BF e.g. 2
IterationNode 0 1 2 3 4 5 6
S 0 0 0 0A ∞ 7 7 7B ∞ ∞ 11 11C ∞ 6 5 5D ∞ ∞ 8 7E ∞ 6 6 6F ∞ 5 4 4G ∞ ∞ ∞ 9H ∞ ∞ 9 7I ∞ ∞ ∞ ∞
![Page 20: 6.17 - Dynamic programming - Exact Changerpeng/CS3510_F17/Notes/Oct16... · 2017. 10. 16. · 6.17 - Dynamic programming - Exact Change Running Time I No. of subproblems: O(v) I Transition](https://reader033.fdocuments.in/reader033/viewer/2022051803/5febecf0a2fcc0722a270b40/html5/thumbnails/20.jpg)
4.2 - BF e.g. 2
IterationNode 0 1 2 3 4 5 6
S 0 0 0 0 0A ∞ 7 7 7 7B ∞ ∞ 11 11 11C ∞ 6 5 5 5D ∞ ∞ 8 7 7E ∞ 6 6 6 6F ∞ 5 4 4 4G ∞ ∞ ∞ 9 8H ∞ ∞ 9 7 7I ∞ ∞ ∞ ∞ 8
![Page 21: 6.17 - Dynamic programming - Exact Changerpeng/CS3510_F17/Notes/Oct16... · 2017. 10. 16. · 6.17 - Dynamic programming - Exact Change Running Time I No. of subproblems: O(v) I Transition](https://reader033.fdocuments.in/reader033/viewer/2022051803/5febecf0a2fcc0722a270b40/html5/thumbnails/21.jpg)
4.2 - BF e.g. 2
IterationNode 0 1 2 3 4 5 6
S 0 0 0 0 0 0A ∞ 7 7 7 7 7B ∞ ∞ 11 11 11 11C ∞ 6 5 5 5 5D ∞ ∞ 8 7 7 7E ∞ 6 6 6 6 6F ∞ 5 4 4 4 4G ∞ ∞ ∞ 9 8 8H ∞ ∞ 9 7 7 7I ∞ ∞ ∞ ∞ 8 7
![Page 22: 6.17 - Dynamic programming - Exact Changerpeng/CS3510_F17/Notes/Oct16... · 2017. 10. 16. · 6.17 - Dynamic programming - Exact Change Running Time I No. of subproblems: O(v) I Transition](https://reader033.fdocuments.in/reader033/viewer/2022051803/5febecf0a2fcc0722a270b40/html5/thumbnails/22.jpg)
4.2 - BF e.g. 2
IterationNode 0 1 2 3 4 5 6
S 0 0 0 0 0 0 0A ∞ 7 7 7 7 7 7B ∞ ∞ 11 11 11 11 11C ∞ 6 5 5 5 5 5D ∞ ∞ 8 7 7 7 7E ∞ 6 6 6 6 6 6F ∞ 5 4 4 4 4 4G ∞ ∞ ∞ 9 8 8 8H ∞ ∞ 9 7 7 7 7I ∞ ∞ ∞ ∞ 8 7 7
![Page 23: 6.17 - Dynamic programming - Exact Changerpeng/CS3510_F17/Notes/Oct16... · 2017. 10. 16. · 6.17 - Dynamic programming - Exact Change Running Time I No. of subproblems: O(v) I Transition](https://reader033.fdocuments.in/reader033/viewer/2022051803/5febecf0a2fcc0722a270b40/html5/thumbnails/23.jpg)
4.2 - BF e.g. 2
Shortest path tree:
![Page 24: 6.17 - Dynamic programming - Exact Changerpeng/CS3510_F17/Notes/Oct16... · 2017. 10. 16. · 6.17 - Dynamic programming - Exact Change Running Time I No. of subproblems: O(v) I Transition](https://reader033.fdocuments.in/reader033/viewer/2022051803/5febecf0a2fcc0722a270b40/html5/thumbnails/24.jpg)
5.1 - Kruskal example 1
Kruskal order:
I AE - yes [cut: A,V − A]I EF - yes [cut: F ,V − F ]I BE - yes [cut: B,V − B]I BF - noI FG - yes [cut: GH,V − GH]I GH - yes [cut: H,V − H]I CG - yes [cut: C ,V − C ]I DG - yes [cut: D,V − D]
n − 1 = 7 edges done!
![Page 25: 6.17 - Dynamic programming - Exact Changerpeng/CS3510_F17/Notes/Oct16... · 2017. 10. 16. · 6.17 - Dynamic programming - Exact Change Running Time I No. of subproblems: O(v) I Transition](https://reader033.fdocuments.in/reader033/viewer/2022051803/5febecf0a2fcc0722a270b40/html5/thumbnails/25.jpg)
5.1 - Kruskal example 1
Kruskal order:
I AE - yes [cut: A,V − A]
I EF - yes [cut: F ,V − F ]I BE - yes [cut: B,V − B]I BF - noI FG - yes [cut: GH,V − GH]I GH - yes [cut: H,V − H]I CG - yes [cut: C ,V − C ]I DG - yes [cut: D,V − D]
n − 1 = 7 edges done!
![Page 26: 6.17 - Dynamic programming - Exact Changerpeng/CS3510_F17/Notes/Oct16... · 2017. 10. 16. · 6.17 - Dynamic programming - Exact Change Running Time I No. of subproblems: O(v) I Transition](https://reader033.fdocuments.in/reader033/viewer/2022051803/5febecf0a2fcc0722a270b40/html5/thumbnails/26.jpg)
5.1 - Kruskal example 1
Kruskal order:
I AE - yes [cut: A,V − A]I EF - yes [cut: F ,V − F ]
I BE - yes [cut: B,V − B]I BF - noI FG - yes [cut: GH,V − GH]I GH - yes [cut: H,V − H]I CG - yes [cut: C ,V − C ]I DG - yes [cut: D,V − D]
n − 1 = 7 edges done!
![Page 27: 6.17 - Dynamic programming - Exact Changerpeng/CS3510_F17/Notes/Oct16... · 2017. 10. 16. · 6.17 - Dynamic programming - Exact Change Running Time I No. of subproblems: O(v) I Transition](https://reader033.fdocuments.in/reader033/viewer/2022051803/5febecf0a2fcc0722a270b40/html5/thumbnails/27.jpg)
5.1 - Kruskal example 1
Kruskal order:
I AE - yes [cut: A,V − A]I EF - yes [cut: F ,V − F ]I BE - yes [cut: B,V − B]
I BF - noI FG - yes [cut: GH,V − GH]I GH - yes [cut: H,V − H]I CG - yes [cut: C ,V − C ]I DG - yes [cut: D,V − D]
n − 1 = 7 edges done!
![Page 28: 6.17 - Dynamic programming - Exact Changerpeng/CS3510_F17/Notes/Oct16... · 2017. 10. 16. · 6.17 - Dynamic programming - Exact Change Running Time I No. of subproblems: O(v) I Transition](https://reader033.fdocuments.in/reader033/viewer/2022051803/5febecf0a2fcc0722a270b40/html5/thumbnails/28.jpg)
5.1 - Kruskal example 1
Kruskal order:
I AE - yes [cut: A,V − A]I EF - yes [cut: F ,V − F ]I BE - yes [cut: B,V − B]I BF - no
I FG - yes [cut: GH,V − GH]I GH - yes [cut: H,V − H]I CG - yes [cut: C ,V − C ]I DG - yes [cut: D,V − D]
n − 1 = 7 edges done!
![Page 29: 6.17 - Dynamic programming - Exact Changerpeng/CS3510_F17/Notes/Oct16... · 2017. 10. 16. · 6.17 - Dynamic programming - Exact Change Running Time I No. of subproblems: O(v) I Transition](https://reader033.fdocuments.in/reader033/viewer/2022051803/5febecf0a2fcc0722a270b40/html5/thumbnails/29.jpg)
5.1 - Kruskal example 1
Kruskal order:
I AE - yes [cut: A,V − A]I EF - yes [cut: F ,V − F ]I BE - yes [cut: B,V − B]I BF - noI FG - yes [cut: GH,V − GH]
I GH - yes [cut: H,V − H]I CG - yes [cut: C ,V − C ]I DG - yes [cut: D,V − D]
n − 1 = 7 edges done!
![Page 30: 6.17 - Dynamic programming - Exact Changerpeng/CS3510_F17/Notes/Oct16... · 2017. 10. 16. · 6.17 - Dynamic programming - Exact Change Running Time I No. of subproblems: O(v) I Transition](https://reader033.fdocuments.in/reader033/viewer/2022051803/5febecf0a2fcc0722a270b40/html5/thumbnails/30.jpg)
5.1 - Kruskal example 1
Kruskal order:
I AE - yes [cut: A,V − A]I EF - yes [cut: F ,V − F ]I BE - yes [cut: B,V − B]I BF - noI FG - yes [cut: GH,V − GH]I GH - yes [cut: H,V − H]
I CG - yes [cut: C ,V − C ]I DG - yes [cut: D,V − D]
n − 1 = 7 edges done!
![Page 31: 6.17 - Dynamic programming - Exact Changerpeng/CS3510_F17/Notes/Oct16... · 2017. 10. 16. · 6.17 - Dynamic programming - Exact Change Running Time I No. of subproblems: O(v) I Transition](https://reader033.fdocuments.in/reader033/viewer/2022051803/5febecf0a2fcc0722a270b40/html5/thumbnails/31.jpg)
5.1 - Kruskal example 1
Kruskal order:
I AE - yes [cut: A,V − A]I EF - yes [cut: F ,V − F ]I BE - yes [cut: B,V − B]I BF - noI FG - yes [cut: GH,V − GH]I GH - yes [cut: H,V − H]I CG - yes [cut: C ,V − C ]
I DG - yes [cut: D,V − D]n − 1 = 7 edges done!
![Page 32: 6.17 - Dynamic programming - Exact Changerpeng/CS3510_F17/Notes/Oct16... · 2017. 10. 16. · 6.17 - Dynamic programming - Exact Change Running Time I No. of subproblems: O(v) I Transition](https://reader033.fdocuments.in/reader033/viewer/2022051803/5febecf0a2fcc0722a270b40/html5/thumbnails/32.jpg)
5.1 - Kruskal example 1
Kruskal order:
I AE - yes [cut: A,V − A]I EF - yes [cut: F ,V − F ]I BE - yes [cut: B,V − B]I BF - noI FG - yes [cut: GH,V − GH]I GH - yes [cut: H,V − H]I CG - yes [cut: C ,V − C ]I DG - yes [cut: D,V − D]
n − 1 = 7 edges done!
![Page 33: 6.17 - Dynamic programming - Exact Changerpeng/CS3510_F17/Notes/Oct16... · 2017. 10. 16. · 6.17 - Dynamic programming - Exact Change Running Time I No. of subproblems: O(v) I Transition](https://reader033.fdocuments.in/reader033/viewer/2022051803/5febecf0a2fcc0722a270b40/html5/thumbnails/33.jpg)
5.2 - Kruskal example 2
I AB - yes [cut: A,V − A]I FG - yes [cut: F ,V − F ]I DG - yes [cut: D,V − D]I GH - yes [cut: H,V − H]I BC - yes [cut: ABE ,V − ABE ]I CG - yes [cut: ABC ,V − ABC ]I CD - noI AE - yes [cut: E ,V − E ]
n − 1 = 7 edges done!
![Page 34: 6.17 - Dynamic programming - Exact Changerpeng/CS3510_F17/Notes/Oct16... · 2017. 10. 16. · 6.17 - Dynamic programming - Exact Change Running Time I No. of subproblems: O(v) I Transition](https://reader033.fdocuments.in/reader033/viewer/2022051803/5febecf0a2fcc0722a270b40/html5/thumbnails/34.jpg)
5.2 - Kruskal example 2
I AB - yes [cut: A,V − A]
I FG - yes [cut: F ,V − F ]I DG - yes [cut: D,V − D]I GH - yes [cut: H,V − H]I BC - yes [cut: ABE ,V − ABE ]I CG - yes [cut: ABC ,V − ABC ]I CD - noI AE - yes [cut: E ,V − E ]
n − 1 = 7 edges done!
![Page 35: 6.17 - Dynamic programming - Exact Changerpeng/CS3510_F17/Notes/Oct16... · 2017. 10. 16. · 6.17 - Dynamic programming - Exact Change Running Time I No. of subproblems: O(v) I Transition](https://reader033.fdocuments.in/reader033/viewer/2022051803/5febecf0a2fcc0722a270b40/html5/thumbnails/35.jpg)
5.2 - Kruskal example 2
I AB - yes [cut: A,V − A]I FG - yes [cut: F ,V − F ]
I DG - yes [cut: D,V − D]I GH - yes [cut: H,V − H]I BC - yes [cut: ABE ,V − ABE ]I CG - yes [cut: ABC ,V − ABC ]I CD - noI AE - yes [cut: E ,V − E ]
n − 1 = 7 edges done!
![Page 36: 6.17 - Dynamic programming - Exact Changerpeng/CS3510_F17/Notes/Oct16... · 2017. 10. 16. · 6.17 - Dynamic programming - Exact Change Running Time I No. of subproblems: O(v) I Transition](https://reader033.fdocuments.in/reader033/viewer/2022051803/5febecf0a2fcc0722a270b40/html5/thumbnails/36.jpg)
5.2 - Kruskal example 2
I AB - yes [cut: A,V − A]I FG - yes [cut: F ,V − F ]I DG - yes [cut: D,V − D]
I GH - yes [cut: H,V − H]I BC - yes [cut: ABE ,V − ABE ]I CG - yes [cut: ABC ,V − ABC ]I CD - noI AE - yes [cut: E ,V − E ]
n − 1 = 7 edges done!
![Page 37: 6.17 - Dynamic programming - Exact Changerpeng/CS3510_F17/Notes/Oct16... · 2017. 10. 16. · 6.17 - Dynamic programming - Exact Change Running Time I No. of subproblems: O(v) I Transition](https://reader033.fdocuments.in/reader033/viewer/2022051803/5febecf0a2fcc0722a270b40/html5/thumbnails/37.jpg)
5.2 - Kruskal example 2
I AB - yes [cut: A,V − A]I FG - yes [cut: F ,V − F ]I DG - yes [cut: D,V − D]I GH - yes [cut: H,V − H]
I BC - yes [cut: ABE ,V − ABE ]I CG - yes [cut: ABC ,V − ABC ]I CD - noI AE - yes [cut: E ,V − E ]
n − 1 = 7 edges done!
![Page 38: 6.17 - Dynamic programming - Exact Changerpeng/CS3510_F17/Notes/Oct16... · 2017. 10. 16. · 6.17 - Dynamic programming - Exact Change Running Time I No. of subproblems: O(v) I Transition](https://reader033.fdocuments.in/reader033/viewer/2022051803/5febecf0a2fcc0722a270b40/html5/thumbnails/38.jpg)
5.2 - Kruskal example 2
I AB - yes [cut: A,V − A]I FG - yes [cut: F ,V − F ]I DG - yes [cut: D,V − D]I GH - yes [cut: H,V − H]I BC - yes [cut: ABE ,V − ABE ]
I CG - yes [cut: ABC ,V − ABC ]I CD - noI AE - yes [cut: E ,V − E ]
n − 1 = 7 edges done!
![Page 39: 6.17 - Dynamic programming - Exact Changerpeng/CS3510_F17/Notes/Oct16... · 2017. 10. 16. · 6.17 - Dynamic programming - Exact Change Running Time I No. of subproblems: O(v) I Transition](https://reader033.fdocuments.in/reader033/viewer/2022051803/5febecf0a2fcc0722a270b40/html5/thumbnails/39.jpg)
5.2 - Kruskal example 2
I AB - yes [cut: A,V − A]I FG - yes [cut: F ,V − F ]I DG - yes [cut: D,V − D]I GH - yes [cut: H,V − H]I BC - yes [cut: ABE ,V − ABE ]I CG - yes [cut: ABC ,V − ABC ]
I CD - noI AE - yes [cut: E ,V − E ]
n − 1 = 7 edges done!
![Page 40: 6.17 - Dynamic programming - Exact Changerpeng/CS3510_F17/Notes/Oct16... · 2017. 10. 16. · 6.17 - Dynamic programming - Exact Change Running Time I No. of subproblems: O(v) I Transition](https://reader033.fdocuments.in/reader033/viewer/2022051803/5febecf0a2fcc0722a270b40/html5/thumbnails/40.jpg)
5.2 - Kruskal example 2
I AB - yes [cut: A,V − A]I FG - yes [cut: F ,V − F ]I DG - yes [cut: D,V − D]I GH - yes [cut: H,V − H]I BC - yes [cut: ABE ,V − ABE ]I CG - yes [cut: ABC ,V − ABC ]I CD - no
I AE - yes [cut: E ,V − E ]n − 1 = 7 edges done!
![Page 41: 6.17 - Dynamic programming - Exact Changerpeng/CS3510_F17/Notes/Oct16... · 2017. 10. 16. · 6.17 - Dynamic programming - Exact Change Running Time I No. of subproblems: O(v) I Transition](https://reader033.fdocuments.in/reader033/viewer/2022051803/5febecf0a2fcc0722a270b40/html5/thumbnails/41.jpg)
5.2 - Kruskal example 2
I AB - yes [cut: A,V − A]I FG - yes [cut: F ,V − F ]I DG - yes [cut: D,V − D]I GH - yes [cut: H,V − H]I BC - yes [cut: ABE ,V − ABE ]I CG - yes [cut: ABC ,V − ABC ]I CD - noI AE - yes [cut: E ,V − E ]
n − 1 = 7 edges done!