SlideShare une entreprise Scribd logo
1  sur  36
Télécharger pour lire hors ligne
CS 321. Algorithm Analysis & Design
Lecture 12
Dynamic Programming
Weighted Independent Sets on Paths
12 - 05 Feb - Dynamic Programming
12 - 05 Feb - Dynamic Programming
23 41 11 19 45 12 15 18 25
Goal: Find the independent set with the largest total weight.
Review Time
23 41 11 19 45 12 15 18 25
Review Time
Try all subsets? Brute Force
23 41 11 19 45 12 15 18 25
Review Time
Try all subsets? Brute Force
23 41 11 19 45 12 15 18 25
GreedyChoose the most tempting option.
Review Time
Try all subsets? Brute Force
23 41 11 19 45 12 15 18 25
GreedyChoose the most tempting option.
1 4 5 4
Review Time
Try all subsets? Brute Force
23 41 11 19 45 12 15 18 25
GreedyChoose the most tempting option.
1 4 5 4
Review Time
Try all subsets? Brute Force
23 41 11 19 45 12 15 18 25
GreedyChoose the most tempting option.
Try all subsets?
Review Time
Brute Force
Greedy
23 41 11 19 45 12 15 18 25
Choose the most tempting option.
Try all subsets?
Review Time
Brute Force
Greedy
23 41 11 19 45 12 15 18 25
Choose the most tempting option.
Split things up? Divide and Conquer
Try all subsets?
Review Time
Brute Force
Greedy
23 41 11 19 45 12 15 18 25
Choose the most tempting option.
Split things up? Divide and Conquer
1 4 5 4
Try all subsets?
Review Time
Brute Force
Greedy
23 41 11 19 45 12 15 18 25
Choose the most tempting option.
Split things up? Divide and Conquer
1 4 5 4
Try all subsets?
Review Time
Brute Force
Greedy
23 41 11 19 45 12 15 18 25
Choose the most tempting option.
Split things up? Divide and Conquer
Try all subsets?
Review Time
Brute Force
Greedy
23 41 11 19 45 12 15 18 25
Choose the most tempting option.
Split things up? Divide and Conquer
Try all subsets?
Review Time
Brute Force
Greedy
23 41 11 19 45 12 15 18 25
Choose the most tempting option.
Split things up? Divide and Conquer
Try Gv versus GN(v)? Recursion
23 41 11 19 45 12 15 18 25
23 41 11 19 45 12 15 18 25
23 41 11 19 45 12 15 18 25
23 41 11 19 45 12 15 18 25
23 41 11 19 45 12 15 25
23 41 11 19 45 12 15 18 25
M(Pn) = max(M(P - {vn}), M(P - {vn-1,vn}) + w(vn))
M(Pn) = max(M(P - {vn}), M(P - {vn-1,vn}) + w(vn))
vn does not belong to the MIS.
vn belongs to the MIS.
M(Pn) = max(M(P - {vn}), M(P - {vn-1,vn}) + w(vn))
vn does not belong to the MIS.
vn belongs to the MIS.
M(Pn) = max(M(P - {vn}), M(P - {vn-1,vn}) + w(vn))
vn does not belong to the MIS.
vn belongs to the MIS.
M(Pn) = max(M(P - {vn}), M(P - {vn-1,vn}) + w(vn))
vn does not belong to the MIS.
vn belongs to the MIS.
12 - 05 Feb - Dynamic Programming
A[i] stores the MIS for P[1…i], and A[n] is the
solution.
A[i] stores the MIS for P[1…i], and A[n] is the
solution.
(What we want)
A[i] stores the MIS for P[1…i], and A[n] is the
solution.
A[i] = max(A(i-1), A[i-2] + w(vi))
(What we want)
A[i] stores the MIS for P[1…i], and A[n] is the
solution.
A[i] = max(A(i-1), A[i-2] + w(vi))
(What we want)
(Build up the array bottom to top.)
12 - 05 Feb - Dynamic Programming
1. Decide what to store.
1. Decide what to store.
2. Figure out how to compute it based on what you store.
A[i] stores the size of the maximum WIS
of the sub-path on the first i vertices.
1. Decide what to store.
2. Figure out how to compute it based on what you store.
A[i] stores the size of the maximum WIS
of the sub-path on the first i vertices.
A[i] = max(A(i-1), A[i-2] + w(vn))
1. Decide what to store.
2. Figure out how to compute it based on what you store.
A[i] stores the size of the maximum WIS
of the sub-path on the first i vertices.
A[i] = max(A(i-1), A[i-2] + w(vn))
1. Decide what to store.
2. Figure out how to compute it based on what you store.

Contenu connexe

Tendances

Longest Common Subsequence & Matrix Chain Multiplication
Longest Common Subsequence & Matrix Chain MultiplicationLongest Common Subsequence & Matrix Chain Multiplication
Longest Common Subsequence & Matrix Chain MultiplicationJaneAlamAdnan
 
Matrix chain multiplication by MHM
Matrix chain multiplication by MHMMatrix chain multiplication by MHM
Matrix chain multiplication by MHMMd Mosharof Hosen
 
Analysis of Algorithm (Bubblesort and Quicksort)
Analysis of Algorithm (Bubblesort and Quicksort)Analysis of Algorithm (Bubblesort and Quicksort)
Analysis of Algorithm (Bubblesort and Quicksort)Flynce Miguel
 
A presentation on prim's and kruskal's algorithm
A presentation on prim's and kruskal's algorithmA presentation on prim's and kruskal's algorithm
A presentation on prim's and kruskal's algorithmGaurav Kolekar
 
Prim Algorithm and kruskal algorithm
Prim Algorithm and kruskal algorithmPrim Algorithm and kruskal algorithm
Prim Algorithm and kruskal algorithmAcad
 
Svm soft margin hyperplanes
Svm   soft margin hyperplanesSvm   soft margin hyperplanes
Svm soft margin hyperplanessarith divakar
 
Appendix b 2
Appendix b 2Appendix b 2
Appendix b 2Loc Tran
 
International Journal of Engineering Research and Development (IJERD)
International Journal of Engineering Research and Development (IJERD)International Journal of Engineering Research and Development (IJERD)
International Journal of Engineering Research and Development (IJERD)IJERD Editor
 
Grds international conference on pure and applied science (6)
Grds international conference on pure and applied science (6)Grds international conference on pure and applied science (6)
Grds international conference on pure and applied science (6)Global R & D Services
 
Ch 5-integration-part-1
Ch 5-integration-part-1Ch 5-integration-part-1
Ch 5-integration-part-1GpmMaths
 
Waldie pd2
Waldie pd2Waldie pd2
Waldie pd2guero456
 

Tendances (19)

Longest Common Subsequence & Matrix Chain Multiplication
Longest Common Subsequence & Matrix Chain MultiplicationLongest Common Subsequence & Matrix Chain Multiplication
Longest Common Subsequence & Matrix Chain Multiplication
 
Matrix chain multiplication by MHM
Matrix chain multiplication by MHMMatrix chain multiplication by MHM
Matrix chain multiplication by MHM
 
Bucket sort
Bucket sortBucket sort
Bucket sort
 
2-rankings of Graphs
2-rankings of Graphs2-rankings of Graphs
2-rankings of Graphs
 
Kruskal Algorithm
Kruskal AlgorithmKruskal Algorithm
Kruskal Algorithm
 
Analysis of Algorithm (Bubblesort and Quicksort)
Analysis of Algorithm (Bubblesort and Quicksort)Analysis of Algorithm (Bubblesort and Quicksort)
Analysis of Algorithm (Bubblesort and Quicksort)
 
Taller 1 parcial 3
Taller 1 parcial 3Taller 1 parcial 3
Taller 1 parcial 3
 
Ponchon Savarait
Ponchon SavaraitPonchon Savarait
Ponchon Savarait
 
A presentation on prim's and kruskal's algorithm
A presentation on prim's and kruskal's algorithmA presentation on prim's and kruskal's algorithm
A presentation on prim's and kruskal's algorithm
 
Graphs
GraphsGraphs
Graphs
 
Prim Algorithm and kruskal algorithm
Prim Algorithm and kruskal algorithmPrim Algorithm and kruskal algorithm
Prim Algorithm and kruskal algorithm
 
Svm soft margin hyperplanes
Svm   soft margin hyperplanesSvm   soft margin hyperplanes
Svm soft margin hyperplanes
 
Appendix b 2
Appendix b 2Appendix b 2
Appendix b 2
 
Appendix b 2
Appendix b 2Appendix b 2
Appendix b 2
 
International Journal of Engineering Research and Development (IJERD)
International Journal of Engineering Research and Development (IJERD)International Journal of Engineering Research and Development (IJERD)
International Journal of Engineering Research and Development (IJERD)
 
Grds international conference on pure and applied science (6)
Grds international conference on pure and applied science (6)Grds international conference on pure and applied science (6)
Grds international conference on pure and applied science (6)
 
Ch 5-integration-part-1
Ch 5-integration-part-1Ch 5-integration-part-1
Ch 5-integration-part-1
 
Waldie pd2
Waldie pd2Waldie pd2
Waldie pd2
 
Mc
McMc
Mc
 

En vedette

[ACM-ICPC] Greedy Algorithm
[ACM-ICPC] Greedy Algorithm[ACM-ICPC] Greedy Algorithm
[ACM-ICPC] Greedy Algorithm陳 鵬宇
 
Sec16 greedy algorithm no2
Sec16 greedy algorithm no2Sec16 greedy algorithm no2
Sec16 greedy algorithm no2Keisuke OTAKI
 
4 greedy methodnew
4 greedy methodnew4 greedy methodnew
4 greedy methodnewabhinav108
 
Better Living Through Computing Algorithms?
Better Living Through Computing Algorithms?Better Living Through Computing Algorithms?
Better Living Through Computing Algorithms?stephtroeth
 
Evolution algorithms
Evolution algorithmsEvolution algorithms
Evolution algorithmsAndrii Babii
 
Kmeans initialization
Kmeans initializationKmeans initialization
Kmeans initializationdjempol
 
Greedy Algorithm-Dijkstra's algo
Greedy Algorithm-Dijkstra's algoGreedy Algorithm-Dijkstra's algo
Greedy Algorithm-Dijkstra's algoJay Patel
 
Greedy method1
Greedy method1Greedy method1
Greedy method1Rajendran
 
Greedyalgorithm
Greedyalgorithm Greedyalgorithm
Greedyalgorithm Diksha Lad
 
Application of greedy method prim
Application of greedy method primApplication of greedy method prim
Application of greedy method primTech_MX
 
Migrating your Web app to Virtual Reality
Migrating your Web app to Virtual RealityMigrating your Web app to Virtual Reality
Migrating your Web app to Virtual RealityDenis Radin
 
Application of greedy method
Application  of  greedy methodApplication  of  greedy method
Application of greedy methodTech_MX
 
Virtual Reality Presentation at #HybridLive
Virtual Reality Presentation at #HybridLiveVirtual Reality Presentation at #HybridLive
Virtual Reality Presentation at #HybridLiveCharles Palmer
 
Best for b trees
Best for b treesBest for b trees
Best for b treesDineshRaaja
 
14 - 08 Feb - Dynamic Programming
14 - 08 Feb - Dynamic Programming14 - 08 Feb - Dynamic Programming
14 - 08 Feb - Dynamic ProgrammingNeeldhara Misra
 

En vedette (20)

[ACM-ICPC] Greedy Algorithm
[ACM-ICPC] Greedy Algorithm[ACM-ICPC] Greedy Algorithm
[ACM-ICPC] Greedy Algorithm
 
Sec16 greedy algorithm no2
Sec16 greedy algorithm no2Sec16 greedy algorithm no2
Sec16 greedy algorithm no2
 
4 greedy methodnew
4 greedy methodnew4 greedy methodnew
4 greedy methodnew
 
Better Living Through Computing Algorithms?
Better Living Through Computing Algorithms?Better Living Through Computing Algorithms?
Better Living Through Computing Algorithms?
 
Evolution algorithms
Evolution algorithmsEvolution algorithms
Evolution algorithms
 
Kmeans initialization
Kmeans initializationKmeans initialization
Kmeans initialization
 
Greedy Algorithm-Dijkstra's algo
Greedy Algorithm-Dijkstra's algoGreedy Algorithm-Dijkstra's algo
Greedy Algorithm-Dijkstra's algo
 
36 greedy
36 greedy36 greedy
36 greedy
 
Greedy method1
Greedy method1Greedy method1
Greedy method1
 
Greedyalgorithm
Greedyalgorithm Greedyalgorithm
Greedyalgorithm
 
Application of greedy method prim
Application of greedy method primApplication of greedy method prim
Application of greedy method prim
 
13 Amortized Analysis
13 Amortized Analysis13 Amortized Analysis
13 Amortized Analysis
 
Migrating your Web app to Virtual Reality
Migrating your Web app to Virtual RealityMigrating your Web app to Virtual Reality
Migrating your Web app to Virtual Reality
 
Application of greedy method
Application  of  greedy methodApplication  of  greedy method
Application of greedy method
 
Greedy
GreedyGreedy
Greedy
 
Virtual Reality Presentation at #HybridLive
Virtual Reality Presentation at #HybridLiveVirtual Reality Presentation at #HybridLive
Virtual Reality Presentation at #HybridLive
 
Virtual Reality
Virtual RealityVirtual Reality
Virtual Reality
 
Best for b trees
Best for b treesBest for b trees
Best for b trees
 
14 - 08 Feb - Dynamic Programming
14 - 08 Feb - Dynamic Programming14 - 08 Feb - Dynamic Programming
14 - 08 Feb - Dynamic Programming
 
B Trees
B TreesB Trees
B Trees
 

Plus de Neeldhara Misra

15 - 12 Feb - Stable Matchings
15 - 12 Feb - Stable Matchings15 - 12 Feb - Stable Matchings
15 - 12 Feb - Stable MatchingsNeeldhara Misra
 
07- 22 Jan - Divide and Conquer
07- 22 Jan - Divide and Conquer07- 22 Jan - Divide and Conquer
07- 22 Jan - Divide and ConquerNeeldhara Misra
 
10 - 29 Jan - Recursion Part 2
10 - 29 Jan - Recursion Part 210 - 29 Jan - Recursion Part 2
10 - 29 Jan - Recursion Part 2Neeldhara Misra
 
05 - 18 Jan - The Sorting Wrap-Up
05 - 18 Jan - The Sorting Wrap-Up05 - 18 Jan - The Sorting Wrap-Up
05 - 18 Jan - The Sorting Wrap-UpNeeldhara Misra
 
02 - 04 Jan - Sorting (Continued)
02 - 04 Jan - Sorting (Continued)02 - 04 Jan - Sorting (Continued)
02 - 04 Jan - Sorting (Continued)Neeldhara Misra
 
08 - 25 Jan - Divide and Conquer
08 - 25 Jan - Divide and Conquer08 - 25 Jan - Divide and Conquer
08 - 25 Jan - Divide and ConquerNeeldhara Misra
 
06 - 20 Jan - Divide and Conquer
06 - 20 Jan - Divide and Conquer06 - 20 Jan - Divide and Conquer
06 - 20 Jan - Divide and ConquerNeeldhara Misra
 
13 - 06 Feb - Dynamic Programming
13 - 06 Feb - Dynamic Programming13 - 06 Feb - Dynamic Programming
13 - 06 Feb - Dynamic ProgrammingNeeldhara Misra
 
00 - 30 Dec - Introduction
00 - 30 Dec - Introduction00 - 30 Dec - Introduction
00 - 30 Dec - IntroductionNeeldhara Misra
 
01 - 01 January - Sorting
01 - 01 January - Sorting01 - 01 January - Sorting
01 - 01 January - SortingNeeldhara Misra
 
11 - 03 Feb - From Recursion to Dynamic Programming
11 - 03 Feb - From Recursion to Dynamic Programming11 - 03 Feb - From Recursion to Dynamic Programming
11 - 03 Feb - From Recursion to Dynamic ProgrammingNeeldhara Misra
 
09 - 27 Jan - Recursion Part 1
09 - 27 Jan - Recursion Part 109 - 27 Jan - Recursion Part 1
09 - 27 Jan - Recursion Part 1Neeldhara Misra
 

Plus de Neeldhara Misra (15)

Erdos Posa Theorem
Erdos Posa TheoremErdos Posa Theorem
Erdos Posa Theorem
 
15 - 12 Feb - Stable Matchings
15 - 12 Feb - Stable Matchings15 - 12 Feb - Stable Matchings
15 - 12 Feb - Stable Matchings
 
07- 22 Jan - Divide and Conquer
07- 22 Jan - Divide and Conquer07- 22 Jan - Divide and Conquer
07- 22 Jan - Divide and Conquer
 
10 - 29 Jan - Recursion Part 2
10 - 29 Jan - Recursion Part 210 - 29 Jan - Recursion Part 2
10 - 29 Jan - Recursion Part 2
 
05 - 18 Jan - The Sorting Wrap-Up
05 - 18 Jan - The Sorting Wrap-Up05 - 18 Jan - The Sorting Wrap-Up
05 - 18 Jan - The Sorting Wrap-Up
 
02 - 04 Jan - Sorting (Continued)
02 - 04 Jan - Sorting (Continued)02 - 04 Jan - Sorting (Continued)
02 - 04 Jan - Sorting (Continued)
 
04 - 15 Jan - Heap Sort
04 - 15 Jan - Heap Sort04 - 15 Jan - Heap Sort
04 - 15 Jan - Heap Sort
 
08 - 25 Jan - Divide and Conquer
08 - 25 Jan - Divide and Conquer08 - 25 Jan - Divide and Conquer
08 - 25 Jan - Divide and Conquer
 
06 - 20 Jan - Divide and Conquer
06 - 20 Jan - Divide and Conquer06 - 20 Jan - Divide and Conquer
06 - 20 Jan - Divide and Conquer
 
13 - 06 Feb - Dynamic Programming
13 - 06 Feb - Dynamic Programming13 - 06 Feb - Dynamic Programming
13 - 06 Feb - Dynamic Programming
 
00 - 30 Dec - Introduction
00 - 30 Dec - Introduction00 - 30 Dec - Introduction
00 - 30 Dec - Introduction
 
01 - 01 January - Sorting
01 - 01 January - Sorting01 - 01 January - Sorting
01 - 01 January - Sorting
 
11 - 03 Feb - From Recursion to Dynamic Programming
11 - 03 Feb - From Recursion to Dynamic Programming11 - 03 Feb - From Recursion to Dynamic Programming
11 - 03 Feb - From Recursion to Dynamic Programming
 
09 - 27 Jan - Recursion Part 1
09 - 27 Jan - Recursion Part 109 - 27 Jan - Recursion Part 1
09 - 27 Jan - Recursion Part 1
 
04 - 15 Jan - Heap Sort
04 - 15 Jan - Heap Sort04 - 15 Jan - Heap Sort
04 - 15 Jan - Heap Sort
 

Dernier

SOLIDE WASTE in Cameroon,,,,,,,,,,,,,,,,,,,,,,,,,,,.pptx
SOLIDE WASTE in Cameroon,,,,,,,,,,,,,,,,,,,,,,,,,,,.pptxSOLIDE WASTE in Cameroon,,,,,,,,,,,,,,,,,,,,,,,,,,,.pptx
SOLIDE WASTE in Cameroon,,,,,,,,,,,,,,,,,,,,,,,,,,,.pptxSyedNadeemGillANi
 
Ultra structure and life cycle of Plasmodium.pptx
Ultra structure and life cycle of Plasmodium.pptxUltra structure and life cycle of Plasmodium.pptx
Ultra structure and life cycle of Plasmodium.pptxDr. Asif Anas
 
3.26.24 Race, the Draft, and the Vietnam War.pptx
3.26.24 Race, the Draft, and the Vietnam War.pptx3.26.24 Race, the Draft, and the Vietnam War.pptx
3.26.24 Race, the Draft, and the Vietnam War.pptxmary850239
 
Department of Health Compounder Question ‍Solution 2022.pdf
Department of Health Compounder Question ‍Solution 2022.pdfDepartment of Health Compounder Question ‍Solution 2022.pdf
Department of Health Compounder Question ‍Solution 2022.pdfMohonDas
 
ARTICULAR DISC OF TEMPOROMANDIBULAR JOINT
ARTICULAR DISC OF TEMPOROMANDIBULAR JOINTARTICULAR DISC OF TEMPOROMANDIBULAR JOINT
ARTICULAR DISC OF TEMPOROMANDIBULAR JOINTDR. SNEHA NAIR
 
How to Solve Singleton Error in the Odoo 17
How to Solve Singleton Error in the  Odoo 17How to Solve Singleton Error in the  Odoo 17
How to Solve Singleton Error in the Odoo 17Celine George
 
HED Office Sohayok Exam Question Solution 2023.pdf
HED Office Sohayok Exam Question Solution 2023.pdfHED Office Sohayok Exam Question Solution 2023.pdf
HED Office Sohayok Exam Question Solution 2023.pdfMohonDas
 
P4C x ELT = P4ELT: Its Theoretical Background (Kanazawa, 2024 March).pdf
P4C x ELT = P4ELT: Its Theoretical Background (Kanazawa, 2024 March).pdfP4C x ELT = P4ELT: Its Theoretical Background (Kanazawa, 2024 March).pdf
P4C x ELT = P4ELT: Its Theoretical Background (Kanazawa, 2024 March).pdfYu Kanazawa / Osaka University
 
The Stolen Bacillus by Herbert George Wells
The Stolen Bacillus by Herbert George WellsThe Stolen Bacillus by Herbert George Wells
The Stolen Bacillus by Herbert George WellsEugene Lysak
 
How to Send Emails From Odoo 17 Using Code
How to Send Emails From Odoo 17 Using CodeHow to Send Emails From Odoo 17 Using Code
How to Send Emails From Odoo 17 Using CodeCeline George
 
DUST OF SNOW_BY ROBERT FROST_EDITED BY_ TANMOY MISHRA
DUST OF SNOW_BY ROBERT FROST_EDITED BY_ TANMOY MISHRADUST OF SNOW_BY ROBERT FROST_EDITED BY_ TANMOY MISHRA
DUST OF SNOW_BY ROBERT FROST_EDITED BY_ TANMOY MISHRATanmoy Mishra
 
Drug Information Services- DIC and Sources.
Drug Information Services- DIC and Sources.Drug Information Services- DIC and Sources.
Drug Information Services- DIC and Sources.raviapr7
 
Unveiling the Intricacies of Leishmania donovani: Structure, Life Cycle, Path...
Unveiling the Intricacies of Leishmania donovani: Structure, Life Cycle, Path...Unveiling the Intricacies of Leishmania donovani: Structure, Life Cycle, Path...
Unveiling the Intricacies of Leishmania donovani: Structure, Life Cycle, Path...Dr. Asif Anas
 
Optical Fibre and It's Applications.pptx
Optical Fibre and It's Applications.pptxOptical Fibre and It's Applications.pptx
Optical Fibre and It's Applications.pptxPurva Nikam
 
Work Experience for psp3 portfolio sasha
Work Experience for psp3 portfolio sashaWork Experience for psp3 portfolio sasha
Work Experience for psp3 portfolio sashasashalaycock03
 
3.21.24 The Origins of Black Power.pptx
3.21.24  The Origins of Black Power.pptx3.21.24  The Origins of Black Power.pptx
3.21.24 The Origins of Black Power.pptxmary850239
 
KARNAADA.pptx made by - saransh dwivedi ( SD ) - SHALAKYA TANTRA - ENT - 4...
KARNAADA.pptx  made by -  saransh dwivedi ( SD ) -  SHALAKYA TANTRA - ENT - 4...KARNAADA.pptx  made by -  saransh dwivedi ( SD ) -  SHALAKYA TANTRA - ENT - 4...
KARNAADA.pptx made by - saransh dwivedi ( SD ) - SHALAKYA TANTRA - ENT - 4...M56BOOKSTORE PRODUCT/SERVICE
 
How to Create a Toggle Button in Odoo 17
How to Create a Toggle Button in Odoo 17How to Create a Toggle Button in Odoo 17
How to Create a Toggle Button in Odoo 17Celine George
 
How to Make a Field read-only in Odoo 17
How to Make a Field read-only in Odoo 17How to Make a Field read-only in Odoo 17
How to Make a Field read-only in Odoo 17Celine George
 
Over the counter (OTC)- Sale, rational use.pptx
Over the counter (OTC)- Sale, rational use.pptxOver the counter (OTC)- Sale, rational use.pptx
Over the counter (OTC)- Sale, rational use.pptxraviapr7
 

Dernier (20)

SOLIDE WASTE in Cameroon,,,,,,,,,,,,,,,,,,,,,,,,,,,.pptx
SOLIDE WASTE in Cameroon,,,,,,,,,,,,,,,,,,,,,,,,,,,.pptxSOLIDE WASTE in Cameroon,,,,,,,,,,,,,,,,,,,,,,,,,,,.pptx
SOLIDE WASTE in Cameroon,,,,,,,,,,,,,,,,,,,,,,,,,,,.pptx
 
Ultra structure and life cycle of Plasmodium.pptx
Ultra structure and life cycle of Plasmodium.pptxUltra structure and life cycle of Plasmodium.pptx
Ultra structure and life cycle of Plasmodium.pptx
 
3.26.24 Race, the Draft, and the Vietnam War.pptx
3.26.24 Race, the Draft, and the Vietnam War.pptx3.26.24 Race, the Draft, and the Vietnam War.pptx
3.26.24 Race, the Draft, and the Vietnam War.pptx
 
Department of Health Compounder Question ‍Solution 2022.pdf
Department of Health Compounder Question ‍Solution 2022.pdfDepartment of Health Compounder Question ‍Solution 2022.pdf
Department of Health Compounder Question ‍Solution 2022.pdf
 
ARTICULAR DISC OF TEMPOROMANDIBULAR JOINT
ARTICULAR DISC OF TEMPOROMANDIBULAR JOINTARTICULAR DISC OF TEMPOROMANDIBULAR JOINT
ARTICULAR DISC OF TEMPOROMANDIBULAR JOINT
 
How to Solve Singleton Error in the Odoo 17
How to Solve Singleton Error in the  Odoo 17How to Solve Singleton Error in the  Odoo 17
How to Solve Singleton Error in the Odoo 17
 
HED Office Sohayok Exam Question Solution 2023.pdf
HED Office Sohayok Exam Question Solution 2023.pdfHED Office Sohayok Exam Question Solution 2023.pdf
HED Office Sohayok Exam Question Solution 2023.pdf
 
P4C x ELT = P4ELT: Its Theoretical Background (Kanazawa, 2024 March).pdf
P4C x ELT = P4ELT: Its Theoretical Background (Kanazawa, 2024 March).pdfP4C x ELT = P4ELT: Its Theoretical Background (Kanazawa, 2024 March).pdf
P4C x ELT = P4ELT: Its Theoretical Background (Kanazawa, 2024 March).pdf
 
The Stolen Bacillus by Herbert George Wells
The Stolen Bacillus by Herbert George WellsThe Stolen Bacillus by Herbert George Wells
The Stolen Bacillus by Herbert George Wells
 
How to Send Emails From Odoo 17 Using Code
How to Send Emails From Odoo 17 Using CodeHow to Send Emails From Odoo 17 Using Code
How to Send Emails From Odoo 17 Using Code
 
DUST OF SNOW_BY ROBERT FROST_EDITED BY_ TANMOY MISHRA
DUST OF SNOW_BY ROBERT FROST_EDITED BY_ TANMOY MISHRADUST OF SNOW_BY ROBERT FROST_EDITED BY_ TANMOY MISHRA
DUST OF SNOW_BY ROBERT FROST_EDITED BY_ TANMOY MISHRA
 
Drug Information Services- DIC and Sources.
Drug Information Services- DIC and Sources.Drug Information Services- DIC and Sources.
Drug Information Services- DIC and Sources.
 
Unveiling the Intricacies of Leishmania donovani: Structure, Life Cycle, Path...
Unveiling the Intricacies of Leishmania donovani: Structure, Life Cycle, Path...Unveiling the Intricacies of Leishmania donovani: Structure, Life Cycle, Path...
Unveiling the Intricacies of Leishmania donovani: Structure, Life Cycle, Path...
 
Optical Fibre and It's Applications.pptx
Optical Fibre and It's Applications.pptxOptical Fibre and It's Applications.pptx
Optical Fibre and It's Applications.pptx
 
Work Experience for psp3 portfolio sasha
Work Experience for psp3 portfolio sashaWork Experience for psp3 portfolio sasha
Work Experience for psp3 portfolio sasha
 
3.21.24 The Origins of Black Power.pptx
3.21.24  The Origins of Black Power.pptx3.21.24  The Origins of Black Power.pptx
3.21.24 The Origins of Black Power.pptx
 
KARNAADA.pptx made by - saransh dwivedi ( SD ) - SHALAKYA TANTRA - ENT - 4...
KARNAADA.pptx  made by -  saransh dwivedi ( SD ) -  SHALAKYA TANTRA - ENT - 4...KARNAADA.pptx  made by -  saransh dwivedi ( SD ) -  SHALAKYA TANTRA - ENT - 4...
KARNAADA.pptx made by - saransh dwivedi ( SD ) - SHALAKYA TANTRA - ENT - 4...
 
How to Create a Toggle Button in Odoo 17
How to Create a Toggle Button in Odoo 17How to Create a Toggle Button in Odoo 17
How to Create a Toggle Button in Odoo 17
 
How to Make a Field read-only in Odoo 17
How to Make a Field read-only in Odoo 17How to Make a Field read-only in Odoo 17
How to Make a Field read-only in Odoo 17
 
Over the counter (OTC)- Sale, rational use.pptx
Over the counter (OTC)- Sale, rational use.pptxOver the counter (OTC)- Sale, rational use.pptx
Over the counter (OTC)- Sale, rational use.pptx
 

12 - 05 Feb - Dynamic Programming

  • 1. CS 321. Algorithm Analysis & Design Lecture 12 Dynamic Programming Weighted Independent Sets on Paths
  • 4. 23 41 11 19 45 12 15 18 25 Goal: Find the independent set with the largest total weight.
  • 5. Review Time 23 41 11 19 45 12 15 18 25
  • 6. Review Time Try all subsets? Brute Force 23 41 11 19 45 12 15 18 25
  • 7. Review Time Try all subsets? Brute Force 23 41 11 19 45 12 15 18 25 GreedyChoose the most tempting option.
  • 8. Review Time Try all subsets? Brute Force 23 41 11 19 45 12 15 18 25 GreedyChoose the most tempting option. 1 4 5 4
  • 9. Review Time Try all subsets? Brute Force 23 41 11 19 45 12 15 18 25 GreedyChoose the most tempting option. 1 4 5 4
  • 10. Review Time Try all subsets? Brute Force 23 41 11 19 45 12 15 18 25 GreedyChoose the most tempting option.
  • 11. Try all subsets? Review Time Brute Force Greedy 23 41 11 19 45 12 15 18 25 Choose the most tempting option.
  • 12. Try all subsets? Review Time Brute Force Greedy 23 41 11 19 45 12 15 18 25 Choose the most tempting option. Split things up? Divide and Conquer
  • 13. Try all subsets? Review Time Brute Force Greedy 23 41 11 19 45 12 15 18 25 Choose the most tempting option. Split things up? Divide and Conquer 1 4 5 4
  • 14. Try all subsets? Review Time Brute Force Greedy 23 41 11 19 45 12 15 18 25 Choose the most tempting option. Split things up? Divide and Conquer 1 4 5 4
  • 15. Try all subsets? Review Time Brute Force Greedy 23 41 11 19 45 12 15 18 25 Choose the most tempting option. Split things up? Divide and Conquer
  • 16. Try all subsets? Review Time Brute Force Greedy 23 41 11 19 45 12 15 18 25 Choose the most tempting option. Split things up? Divide and Conquer
  • 17. Try all subsets? Review Time Brute Force Greedy 23 41 11 19 45 12 15 18 25 Choose the most tempting option. Split things up? Divide and Conquer Try Gv versus GN(v)? Recursion
  • 18. 23 41 11 19 45 12 15 18 25 23 41 11 19 45 12 15 18 25
  • 19. 23 41 11 19 45 12 15 18 25 23 41 11 19 45 12 15 18 25
  • 20. 23 41 11 19 45 12 15 25 23 41 11 19 45 12 15 18 25
  • 21. M(Pn) = max(M(P - {vn}), M(P - {vn-1,vn}) + w(vn))
  • 22. M(Pn) = max(M(P - {vn}), M(P - {vn-1,vn}) + w(vn)) vn does not belong to the MIS. vn belongs to the MIS.
  • 23. M(Pn) = max(M(P - {vn}), M(P - {vn-1,vn}) + w(vn)) vn does not belong to the MIS. vn belongs to the MIS.
  • 24. M(Pn) = max(M(P - {vn}), M(P - {vn-1,vn}) + w(vn)) vn does not belong to the MIS. vn belongs to the MIS.
  • 25. M(Pn) = max(M(P - {vn}), M(P - {vn-1,vn}) + w(vn)) vn does not belong to the MIS. vn belongs to the MIS.
  • 27. A[i] stores the MIS for P[1…i], and A[n] is the solution.
  • 28. A[i] stores the MIS for P[1…i], and A[n] is the solution. (What we want)
  • 29. A[i] stores the MIS for P[1…i], and A[n] is the solution. A[i] = max(A(i-1), A[i-2] + w(vi)) (What we want)
  • 30. A[i] stores the MIS for P[1…i], and A[n] is the solution. A[i] = max(A(i-1), A[i-2] + w(vi)) (What we want) (Build up the array bottom to top.)
  • 32. 1. Decide what to store.
  • 33. 1. Decide what to store. 2. Figure out how to compute it based on what you store.
  • 34. A[i] stores the size of the maximum WIS of the sub-path on the first i vertices. 1. Decide what to store. 2. Figure out how to compute it based on what you store.
  • 35. A[i] stores the size of the maximum WIS of the sub-path on the first i vertices. A[i] = max(A(i-1), A[i-2] + w(vn)) 1. Decide what to store. 2. Figure out how to compute it based on what you store.
  • 36. A[i] stores the size of the maximum WIS of the sub-path on the first i vertices. A[i] = max(A(i-1), A[i-2] + w(vn)) 1. Decide what to store. 2. Figure out how to compute it based on what you store.