SlideShare a Scribd company logo
1 of 39
[object Object],[object Object],[object Object]
Review: Dynamic programming ,[object Object],[object Object],[object Object],[object Object],[object Object]
Properties of a problem that can be solved with dynamic programming ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Review:  Longest Common Subsequence (LCS) ,[object Object],[object Object],[object Object],[object Object]
Review:  Longest Common Subsequence (LCS) continued ,[object Object],[object Object],[object Object],[object Object],c[m,n] is the final solution
Review:  Longest Common Subsequence (LCS) ,[object Object],[object Object]
0-1 Knapsack problem ,[object Object],[object Object],[object Object]
0-1 Knapsack problem: a picture w i b i 10 9 8 5 5 4 4 3 3 2 Weight Benefit value This is a knapsack Max weight: W = 20 Items W = 20
0-1 Knapsack problem ,[object Object],[object Object],[object Object]
0-1 Knapsack problem: brute-force approach ,[object Object],[object Object],[object Object],[object Object]
0-1 Knapsack problem: brute-force approach ,[object Object],[object Object],[object Object],Let’s try this: If items are labeled  1..n , then a subproblem  would be to find an optimal solution for  S k  = {items labeled 1, 2, .. k}
Defining a Subproblem  ,[object Object],[object Object],[object Object],[object Object]
Defining a Subproblem Max weight: W = 20 For S 4 : Total weight: 14; total benefit: 20 w i b i 10 8 5 5 4 4 3 3 2 Weight Benefit 9 Item # 4 3 2 1 5 S 4 S 5 For S 5 : Total weight: 20 total benefit: 26 Solution for S 4  is not part of the solution for S 5 !!! ? w 1  =2 b 1  =3 w 2  =4 b 2  =5 w 3  =5 b 3  =8 w 4  =3 b 4  =4 w 1  =2 b 1  =3 w 2  =4 b 2  =5 w 3  =5 b 3  =8 w 4  =9 b 4  =10
Defining a Subproblem (continued) ,[object Object],[object Object],[object Object],[object Object]
Recursive Formula for subproblems ,[object Object],[object Object],[object Object],[object Object]
Recursive Formula ,[object Object],[object Object],[object Object]
0-1 Knapsack Algorithm ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Running time ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],What is the running time of this algorithm? O(W) O(W) Repeat  n  times O(n*W) Remember that the brute-force algorithm  takes O(2 n )
Example Let’s run our algorithm on the  following data: n = 4 (# of elements) W = 5 (max weight) Elements (weight, benefit): (2,3), (3,4), (4,5), (5,6)
Example (2) for w = 0 to W B[0,w] = 0 0 0 0 0 0 0 W 0 1 2 3 4 5 i 0 1 2 3 4
Example (3) for i = 0 to n B[i,0] = 0 0 0 0 0 0 0 W 0 1 2 3 4 5 i 0 1 2 3 0 0 0 0 4
Example (4) if w i  <= w  // item i can be part of the solution if b i  + B[i-1,w-w i ] > B[i-1,w] B[i,w] = b i  + B[i-1,w- w i ] else B[i,w] = B[i-1,w] else  B[i,w] = B[i-1,w]   // w i  > w  0 0 0 0 0 0 W 0 1 2 3 4 5 i 0 1 2 3 0 0 0 0 i=1 b i =3 w i =2 w= 1 w-w i  =-1 Items: 1: (2,3) 2: (3,4) 3: (4,5)  4: (5,6) 4 0
Example (5) if  w i  <= w   // item i can be part of the solution if  b i  + B[i-1,w-w i ] > B[i-1,w] B[i,w] = b i  + B[i-1,w- w i ] else B[i,w] = B[i-1,w] else B[i,w] = B[i-1,w]  // w i  > w  0 0 0 0 0 0 W 0 1 2 3 4 5 i 0 1 2 3 0 0 0 0 i=1 b i =3 w i =2 w= 2 w-w i  =0 Items: 1: (2,3) 2: (3,4) 3: (4,5)  4: (5,6) 4 0 3
Example (6) if  w i  <= w   // item i can be part of the solution if  b i  + B[i-1,w-w i ] > B[i-1,w] B[i,w] = b i  + B[i-1,w- w i ] else B[i,w] = B[i-1,w] else B[i,w] = B[i-1,w]  // w i  > w  0 0 0 0 0 0 W 0 1 2 3 4 5 i 0 1 2 3 0 0 0 0 i=1 b i =3 w i =2 w= 3 w-w i =1 Items: 1: (2,3) 2: (3,4) 3: (4,5)  4: (5,6) 4 0 3 3
Example (7) if  w i  <= w   // item i can be part of the solution if  b i  + B[i-1,w-w i ] > B[i-1,w] B[i,w] = b i  + B[i-1,w- w i ] else B[i,w] = B[i-1,w] else B[i,w] = B[i-1,w]  // w i  > w  0 0 0 0 0 0 W 0 1 2 3 4 5 i 0 1 2 3 0 0 0 0 i=1 b i =3 w i =2 w= 4 w-w i =2 Items: 1: (2,3) 2: (3,4) 3: (4,5)  4: (5,6) 4 0 3 3 3
Example (8) if  w i  <= w   // item i can be part of the solution if  b i  + B[i-1,w-w i ] > B[i-1,w] B[i,w] = b i  + B[i-1,w- w i ] else B[i,w] = B[i-1,w] else B[i,w] = B[i-1,w]  // w i  > w  0 0 0 0 0 0 W 0 1 2 3 4 5 i 0 1 2 3 0 0 0 0 i=1 b i =3 w i =2 w= 5 w-w i =2 Items: 1: (2,3) 2: (3,4) 3: (4,5)  4: (5,6) 4 0 3 3 3 3
Example (9) if w i  <= w  // item i can be part of the solution if b i  + B[i-1,w-w i ] > B[i-1,w] B[i,w] = b i  + B[i-1,w- w i ] else B[i,w] = B[i-1,w] else   B[i,w] = B[i-1,w]   // w i  > w  0 0 0 0 0 0 W 0 1 2 3 4 5 i 0 1 2 3 0 0 0 0 i=2 b i =4 w i =3 w= 1 w-w i =-2 Items: 1: (2,3) 2: (3,4) 3: (4,5)  4: (5,6) 4 0 3 3 3 3 0
Example (10) if w i  <= w  // item i can be part of the solution if b i  + B[i-1,w-w i ] > B[i-1,w] B[i,w] = b i  + B[i-1,w- w i ] else B[i,w] = B[i-1,w] else   B[i,w] = B[i-1,w]   // w i  > w  0 0 0 0 0 0 W 0 1 2 3 4 5 i 0 1 2 3 0 0 0 0 i=2 b i =4 w i =3 w= 2 w-w i =-1 Items: 1: (2,3) 2: (3,4) 3: (4,5)  4: (5,6) 4 0 3 3 3 3 0 3
Example (11) if  w i  <= w   // item i can be part of the solution if  b i  + B[i-1,w-w i ] > B[i-1,w] B[i,w] = b i  + B[i-1,w- w i ] else B[i,w] = B[i-1,w] else B[i,w] = B[i-1,w]  // w i  > w  0 0 0 0 0 0 W 0 1 2 3 4 5 i 0 1 2 3 0 0 0 0 i=2 b i =4 w i =3 w= 3 w-w i =0 Items: 1: (2,3) 2: (3,4) 3: (4,5)  4: (5,6) 4 0 3 3 3 3 0 3 4
Example (12) if  w i  <= w   // item i can be part of the solution if  b i  + B[i-1,w-w i ] > B[i-1,w] B[i,w] = b i  + B[i-1,w- w i ] else B[i,w] = B[i-1,w] else B[i,w] = B[i-1,w]  // w i  > w  0 0 0 0 0 0 W 0 1 2 3 4 5 i 0 1 2 3 0 0 0 0 i=2 b i =4 w i =3 w= 4 w-w i =1 Items: 1: (2,3) 2: (3,4) 3: (4,5)  4: (5,6) 4 0 3 3 3 3 0 3 4 4
Example (13) if  w i  <= w   // item i can be part of the solution if  b i  + B[i-1,w-w i ] > B[i-1,w] B[i,w] = b i  + B[i-1,w- w i ] else B[i,w] = B[i-1,w] else B[i,w] = B[i-1,w]  // w i  > w  0 0 0 0 0 0 W 0 1 2 3 4 5 i 0 1 2 3 0 0 0 0 i=2 b i =4 w i =3 w= 5 w-w i =2 Items: 1: (2,3) 2: (3,4) 3: (4,5)  4: (5,6) 4 0 3 3 3 3 0 3 4 4 7
Example (14) if w i  <= w  // item i can be part of the solution if b i  + B[i-1,w-w i ] > B[i-1,w] B[i,w] = b i  + B[i-1,w- w i ] else B[i,w] = B[i-1,w] else   B[i,w] = B[i-1,w]   // w i  > w  0 0 0 0 0 0 W 0 1 2 3 4 5 i 0 1 2 3 0 0 0 0 i=3 b i =5 w i =4 w= 1..3 Items: 1: (2,3) 2: (3,4) 3: (4,5)  4: (5,6) 4 0 3 3 3 3 0 0 3 4 4 7 0 3 4
Example (15) if  w i  <= w   // item i can be part of the solution if  b i  + B[i-1,w-w i ] > B[i-1,w] B[i,w] = b i  + B[i-1,w- w i ] else B[i,w] = B[i-1,w] else B[i,w] = B[i-1,w]  // w i  > w  0 0 0 0 0 0 W 0 1 2 3 4 5 i 0 1 2 3 0 0 0 0 i=3 b i =5 w i =4 w= 4 w- w i =0 Items: 1: (2,3) 2: (3,4) 3: (4,5)  4: (5,6) 4 0 0 0 3 4 4 7 0 3 4 5 3 3 3 3
Example (15) if  w i  <= w   // item i can be part of the solution if b i  + B[i-1,w-w i ] > B[i-1,w] B[i,w] = b i  + B[i-1,w- w i ] else B[i,w] = B[i-1,w] else B[i,w] = B[i-1,w]  // w i  > w  0 0 0 0 0 0 W 0 1 2 3 4 5 i 0 1 2 3 0 0 0 0 i=3 b i =5 w i =4 w= 5 w- w i =1 Items: 1: (2,3) 2: (3,4) 3: (4,5)  4: (5,6) 4 0 0 0 3 4 4 7 0 3 4 5 7 3 3 3 3
Example (16) if w i  <= w  // item i can be part of the solution if b i  + B[i-1,w-w i ] > B[i-1,w] B[i,w] = b i  + B[i-1,w- w i ] else B[i,w] = B[i-1,w] else  B[i,w] = B[i-1,w]   // w i  > w  0 0 0 0 0 0 W 0 1 2 3 4 5 i 0 1 2 3 0 0 0 0 i=3 b i =5 w i =4 w= 1..4 Items: 1: (2,3) 2: (3,4) 3: (4,5)  4: (5,6) 4 0 0 0 3 4 4 7 0 3 4 5 7 0 3 4 5 3 3 3 3
Example (17) if  w i  <= w   // item i can be part of the solution if b i  + B[i-1,w-w i ] > B[i-1,w] B[i,w] = b i  + B[i-1,w- w i ] else B[i,w] = B[i-1,w] else B[i,w] = B[i-1,w]  // w i  > w  0 0 0 0 0 0 W 0 1 2 3 4 5 i 0 1 2 3 0 0 0 0 i=3 b i =5 w i =4 w= 5 Items: 1: (2,3) 2: (3,4) 3: (4,5)  4: (5,6) 4 0 0 0 3 4 4 7 0 3 4 5 7 0 3 4 5 7 3 3 3 3
Comments ,[object Object],[object Object],[object Object]
Conclusion ,[object Object],[object Object],[object Object],[object Object],[object Object]
The End

More Related Content

What's hot

Knapsack Dynamic
Knapsack DynamicKnapsack Dynamic
Knapsack DynamicParas Patel
 
0/1 knapsack
0/1 knapsack0/1 knapsack
0/1 knapsackAmin Omi
 
0-1 KNAPSACK PROBLEM
0-1 KNAPSACK PROBLEM0-1 KNAPSACK PROBLEM
0-1 KNAPSACK PROBLEMi i
 
Presentation of knapsack
Presentation of knapsackPresentation of knapsack
Presentation of knapsackGaurav Dubey
 
Simultaneous Triple Series Equations Involving Konhauser Biorthogonal Polynom...
Simultaneous Triple Series Equations Involving Konhauser Biorthogonal Polynom...Simultaneous Triple Series Equations Involving Konhauser Biorthogonal Polynom...
Simultaneous Triple Series Equations Involving Konhauser Biorthogonal Polynom...IOSR Journals
 
A Study on Intuitionistic Multi-Anti Fuzzy Subgroups
A Study on Intuitionistic Multi-Anti Fuzzy Subgroups A Study on Intuitionistic Multi-Anti Fuzzy Subgroups
A Study on Intuitionistic Multi-Anti Fuzzy Subgroups mathsjournal
 
A fixed point theorem for weakly c contraction mappings of integral type.
A fixed point theorem for  weakly c   contraction mappings of integral type.A fixed point theorem for  weakly c   contraction mappings of integral type.
A fixed point theorem for weakly c contraction mappings of integral type.Alexander Decker
 
Neutrosophic Soft Topological Spaces on New Operations
Neutrosophic Soft Topological Spaces on New OperationsNeutrosophic Soft Topological Spaces on New Operations
Neutrosophic Soft Topological Spaces on New OperationsIJSRED
 
Integration 2 elur niahc
Integration 2 elur niahcIntegration 2 elur niahc
Integration 2 elur niahcShaun Wilson
 
FACTORING CRYPTOSYSTEM MODULI WHEN THE CO-FACTORS DIFFERENCE IS BOUNDED
FACTORING CRYPTOSYSTEM MODULI WHEN THE CO-FACTORS DIFFERENCE IS BOUNDEDFACTORING CRYPTOSYSTEM MODULI WHEN THE CO-FACTORS DIFFERENCE IS BOUNDED
FACTORING CRYPTOSYSTEM MODULI WHEN THE CO-FACTORS DIFFERENCE IS BOUNDEDZac Darcy
 
0/1 DYNAMIC PROGRAMMING KNAPSACK PROBLEM
0/1 DYNAMIC PROGRAMMING KNAPSACK PROBLEM0/1 DYNAMIC PROGRAMMING KNAPSACK PROBLEM
0/1 DYNAMIC PROGRAMMING KNAPSACK PROBLEMMrunal Patil
 
On Fuzzy Soft Multi Set and Its Application in Information Systems
On Fuzzy Soft Multi Set and Its Application in Information Systems On Fuzzy Soft Multi Set and Its Application in Information Systems
On Fuzzy Soft Multi Set and Its Application in Information Systems ijcax
 

What's hot (20)

Knapsack Dynamic
Knapsack DynamicKnapsack Dynamic
Knapsack Dynamic
 
0/1 knapsack
0/1 knapsack0/1 knapsack
0/1 knapsack
 
0-1 KNAPSACK PROBLEM
0-1 KNAPSACK PROBLEM0-1 KNAPSACK PROBLEM
0-1 KNAPSACK PROBLEM
 
Presentation of knapsack
Presentation of knapsackPresentation of knapsack
Presentation of knapsack
 
Knapsack dp
Knapsack dpKnapsack dp
Knapsack dp
 
Simultaneous Triple Series Equations Involving Konhauser Biorthogonal Polynom...
Simultaneous Triple Series Equations Involving Konhauser Biorthogonal Polynom...Simultaneous Triple Series Equations Involving Konhauser Biorthogonal Polynom...
Simultaneous Triple Series Equations Involving Konhauser Biorthogonal Polynom...
 
0-1 knapsack problem
0-1 knapsack problem0-1 knapsack problem
0-1 knapsack problem
 
A Study on Intuitionistic Multi-Anti Fuzzy Subgroups
A Study on Intuitionistic Multi-Anti Fuzzy Subgroups A Study on Intuitionistic Multi-Anti Fuzzy Subgroups
A Study on Intuitionistic Multi-Anti Fuzzy Subgroups
 
A fixed point theorem for weakly c contraction mappings of integral type.
A fixed point theorem for  weakly c   contraction mappings of integral type.A fixed point theorem for  weakly c   contraction mappings of integral type.
A fixed point theorem for weakly c contraction mappings of integral type.
 
Neutrosophic Soft Topological Spaces on New Operations
Neutrosophic Soft Topological Spaces on New OperationsNeutrosophic Soft Topological Spaces on New Operations
Neutrosophic Soft Topological Spaces on New Operations
 
Indefinite Integral 18
Indefinite Integral 18Indefinite Integral 18
Indefinite Integral 18
 
Integration 2 elur niahc
Integration 2 elur niahcIntegration 2 elur niahc
Integration 2 elur niahc
 
redes neuronais
redes neuronaisredes neuronais
redes neuronais
 
Spherical interval-valued fuzzy bi-ideals of gamma near-rings
Spherical interval-valued fuzzy bi-ideals of gamma near-ringsSpherical interval-valued fuzzy bi-ideals of gamma near-rings
Spherical interval-valued fuzzy bi-ideals of gamma near-rings
 
Alg1 lesson 7-2
Alg1 lesson 7-2Alg1 lesson 7-2
Alg1 lesson 7-2
 
FACTORING CRYPTOSYSTEM MODULI WHEN THE CO-FACTORS DIFFERENCE IS BOUNDED
FACTORING CRYPTOSYSTEM MODULI WHEN THE CO-FACTORS DIFFERENCE IS BOUNDEDFACTORING CRYPTOSYSTEM MODULI WHEN THE CO-FACTORS DIFFERENCE IS BOUNDED
FACTORING CRYPTOSYSTEM MODULI WHEN THE CO-FACTORS DIFFERENCE IS BOUNDED
 
0/1 DYNAMIC PROGRAMMING KNAPSACK PROBLEM
0/1 DYNAMIC PROGRAMMING KNAPSACK PROBLEM0/1 DYNAMIC PROGRAMMING KNAPSACK PROBLEM
0/1 DYNAMIC PROGRAMMING KNAPSACK PROBLEM
 
50320140501001
5032014050100150320140501001
50320140501001
 
Chapter002math
Chapter002mathChapter002math
Chapter002math
 
On Fuzzy Soft Multi Set and Its Application in Information Systems
On Fuzzy Soft Multi Set and Its Application in Information Systems On Fuzzy Soft Multi Set and Its Application in Information Systems
On Fuzzy Soft Multi Set and Its Application in Information Systems
 

Similar to lecture 25

DynProg_Knapsack.ppt
DynProg_Knapsack.pptDynProg_Knapsack.ppt
DynProg_Knapsack.pptRuchika Sinha
 
Dynamic Programming knapsack 0 1
Dynamic Programming knapsack 0 1Dynamic Programming knapsack 0 1
Dynamic Programming knapsack 0 1Amit Kumar Rathi
 
Longest common sub sequence & 0/1 Knapsack
Longest common sub sequence & 0/1 KnapsackLongest common sub sequence & 0/1 Knapsack
Longest common sub sequence & 0/1 KnapsackAsif Shahriar
 
Dynamic Programming for 4th sem cse students
Dynamic Programming for 4th sem cse studentsDynamic Programming for 4th sem cse students
Dynamic Programming for 4th sem cse studentsDeepakGowda357858
 
Greedy algo revision 2
Greedy algo revision 2Greedy algo revision 2
Greedy algo revision 2maamir farooq
 
Knapsack problem
Knapsack problemKnapsack problem
Knapsack problemRacksaviR
 

Similar to lecture 25 (7)

DynProg_Knapsack.ppt
DynProg_Knapsack.pptDynProg_Knapsack.ppt
DynProg_Knapsack.ppt
 
0-1 knapsack.ppt
0-1 knapsack.ppt0-1 knapsack.ppt
0-1 knapsack.ppt
 
Dynamic Programming knapsack 0 1
Dynamic Programming knapsack 0 1Dynamic Programming knapsack 0 1
Dynamic Programming knapsack 0 1
 
Longest common sub sequence & 0/1 Knapsack
Longest common sub sequence & 0/1 KnapsackLongest common sub sequence & 0/1 Knapsack
Longest common sub sequence & 0/1 Knapsack
 
Dynamic Programming for 4th sem cse students
Dynamic Programming for 4th sem cse studentsDynamic Programming for 4th sem cse students
Dynamic Programming for 4th sem cse students
 
Greedy algo revision 2
Greedy algo revision 2Greedy algo revision 2
Greedy algo revision 2
 
Knapsack problem
Knapsack problemKnapsack problem
Knapsack problem
 

More from sajinsc

lecture 30
lecture 30lecture 30
lecture 30sajinsc
 
lecture 29
lecture 29lecture 29
lecture 29sajinsc
 
lecture 28
lecture 28lecture 28
lecture 28sajinsc
 
lecture 27
lecture 27lecture 27
lecture 27sajinsc
 
lecture 26
lecture 26lecture 26
lecture 26sajinsc
 
lecture 24
lecture 24lecture 24
lecture 24sajinsc
 
lecture 23
lecture 23lecture 23
lecture 23sajinsc
 
lecture 22
lecture 22lecture 22
lecture 22sajinsc
 
lecture 21
lecture 21lecture 21
lecture 21sajinsc
 
lecture 20
lecture 20lecture 20
lecture 20sajinsc
 
lecture 19
lecture 19lecture 19
lecture 19sajinsc
 
lecture 18
lecture 18lecture 18
lecture 18sajinsc
 
lecture 17
lecture 17lecture 17
lecture 17sajinsc
 
lecture 16
lecture 16lecture 16
lecture 16sajinsc
 
lecture 15
lecture 15lecture 15
lecture 15sajinsc
 
lecture 14
lecture 14lecture 14
lecture 14sajinsc
 
lecture 13
lecture 13lecture 13
lecture 13sajinsc
 
lecture 12
lecture 12lecture 12
lecture 12sajinsc
 
lecture 11
lecture 11lecture 11
lecture 11sajinsc
 
lecture 10
lecture 10lecture 10
lecture 10sajinsc
 

More from sajinsc (20)

lecture 30
lecture 30lecture 30
lecture 30
 
lecture 29
lecture 29lecture 29
lecture 29
 
lecture 28
lecture 28lecture 28
lecture 28
 
lecture 27
lecture 27lecture 27
lecture 27
 
lecture 26
lecture 26lecture 26
lecture 26
 
lecture 24
lecture 24lecture 24
lecture 24
 
lecture 23
lecture 23lecture 23
lecture 23
 
lecture 22
lecture 22lecture 22
lecture 22
 
lecture 21
lecture 21lecture 21
lecture 21
 
lecture 20
lecture 20lecture 20
lecture 20
 
lecture 19
lecture 19lecture 19
lecture 19
 
lecture 18
lecture 18lecture 18
lecture 18
 
lecture 17
lecture 17lecture 17
lecture 17
 
lecture 16
lecture 16lecture 16
lecture 16
 
lecture 15
lecture 15lecture 15
lecture 15
 
lecture 14
lecture 14lecture 14
lecture 14
 
lecture 13
lecture 13lecture 13
lecture 13
 
lecture 12
lecture 12lecture 12
lecture 12
 
lecture 11
lecture 11lecture 11
lecture 11
 
lecture 10
lecture 10lecture 10
lecture 10
 

Recently uploaded

Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Celine George
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxHumphrey A Beña
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Celine George
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPCeline George
 
Science 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxScience 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxMaryGraceBautista27
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxAshokKarra1
 
Judging the Relevance and worth of ideas part 2.pptx
Judging the Relevance  and worth of ideas part 2.pptxJudging the Relevance  and worth of ideas part 2.pptx
Judging the Relevance and worth of ideas part 2.pptxSherlyMaeNeri
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...Postal Advocate Inc.
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Jisc
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONHumphrey A Beña
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfMr Bounab Samir
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Celine George
 
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxBarangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxCarlos105
 

Recently uploaded (20)

Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERP
 
Science 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxScience 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptx
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptx
 
Judging the Relevance and worth of ideas part 2.pptx
Judging the Relevance  and worth of ideas part 2.pptxJudging the Relevance  and worth of ideas part 2.pptx
Judging the Relevance and worth of ideas part 2.pptx
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...
 
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptxYOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17
 
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxBarangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
 
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptxYOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
 
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptxFINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
 
Raw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptxRaw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptx
 

lecture 25

  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8. 0-1 Knapsack problem: a picture w i b i 10 9 8 5 5 4 4 3 3 2 Weight Benefit value This is a knapsack Max weight: W = 20 Items W = 20
  • 9.
  • 10.
  • 11.
  • 12.
  • 13. Defining a Subproblem Max weight: W = 20 For S 4 : Total weight: 14; total benefit: 20 w i b i 10 8 5 5 4 4 3 3 2 Weight Benefit 9 Item # 4 3 2 1 5 S 4 S 5 For S 5 : Total weight: 20 total benefit: 26 Solution for S 4 is not part of the solution for S 5 !!! ? w 1 =2 b 1 =3 w 2 =4 b 2 =5 w 3 =5 b 3 =8 w 4 =3 b 4 =4 w 1 =2 b 1 =3 w 2 =4 b 2 =5 w 3 =5 b 3 =8 w 4 =9 b 4 =10
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19. Example Let’s run our algorithm on the following data: n = 4 (# of elements) W = 5 (max weight) Elements (weight, benefit): (2,3), (3,4), (4,5), (5,6)
  • 20. Example (2) for w = 0 to W B[0,w] = 0 0 0 0 0 0 0 W 0 1 2 3 4 5 i 0 1 2 3 4
  • 21. Example (3) for i = 0 to n B[i,0] = 0 0 0 0 0 0 0 W 0 1 2 3 4 5 i 0 1 2 3 0 0 0 0 4
  • 22. Example (4) if w i <= w // item i can be part of the solution if b i + B[i-1,w-w i ] > B[i-1,w] B[i,w] = b i + B[i-1,w- w i ] else B[i,w] = B[i-1,w] else B[i,w] = B[i-1,w] // w i > w 0 0 0 0 0 0 W 0 1 2 3 4 5 i 0 1 2 3 0 0 0 0 i=1 b i =3 w i =2 w= 1 w-w i =-1 Items: 1: (2,3) 2: (3,4) 3: (4,5) 4: (5,6) 4 0
  • 23. Example (5) if w i <= w // item i can be part of the solution if b i + B[i-1,w-w i ] > B[i-1,w] B[i,w] = b i + B[i-1,w- w i ] else B[i,w] = B[i-1,w] else B[i,w] = B[i-1,w] // w i > w 0 0 0 0 0 0 W 0 1 2 3 4 5 i 0 1 2 3 0 0 0 0 i=1 b i =3 w i =2 w= 2 w-w i =0 Items: 1: (2,3) 2: (3,4) 3: (4,5) 4: (5,6) 4 0 3
  • 24. Example (6) if w i <= w // item i can be part of the solution if b i + B[i-1,w-w i ] > B[i-1,w] B[i,w] = b i + B[i-1,w- w i ] else B[i,w] = B[i-1,w] else B[i,w] = B[i-1,w] // w i > w 0 0 0 0 0 0 W 0 1 2 3 4 5 i 0 1 2 3 0 0 0 0 i=1 b i =3 w i =2 w= 3 w-w i =1 Items: 1: (2,3) 2: (3,4) 3: (4,5) 4: (5,6) 4 0 3 3
  • 25. Example (7) if w i <= w // item i can be part of the solution if b i + B[i-1,w-w i ] > B[i-1,w] B[i,w] = b i + B[i-1,w- w i ] else B[i,w] = B[i-1,w] else B[i,w] = B[i-1,w] // w i > w 0 0 0 0 0 0 W 0 1 2 3 4 5 i 0 1 2 3 0 0 0 0 i=1 b i =3 w i =2 w= 4 w-w i =2 Items: 1: (2,3) 2: (3,4) 3: (4,5) 4: (5,6) 4 0 3 3 3
  • 26. Example (8) if w i <= w // item i can be part of the solution if b i + B[i-1,w-w i ] > B[i-1,w] B[i,w] = b i + B[i-1,w- w i ] else B[i,w] = B[i-1,w] else B[i,w] = B[i-1,w] // w i > w 0 0 0 0 0 0 W 0 1 2 3 4 5 i 0 1 2 3 0 0 0 0 i=1 b i =3 w i =2 w= 5 w-w i =2 Items: 1: (2,3) 2: (3,4) 3: (4,5) 4: (5,6) 4 0 3 3 3 3
  • 27. Example (9) if w i <= w // item i can be part of the solution if b i + B[i-1,w-w i ] > B[i-1,w] B[i,w] = b i + B[i-1,w- w i ] else B[i,w] = B[i-1,w] else B[i,w] = B[i-1,w] // w i > w 0 0 0 0 0 0 W 0 1 2 3 4 5 i 0 1 2 3 0 0 0 0 i=2 b i =4 w i =3 w= 1 w-w i =-2 Items: 1: (2,3) 2: (3,4) 3: (4,5) 4: (5,6) 4 0 3 3 3 3 0
  • 28. Example (10) if w i <= w // item i can be part of the solution if b i + B[i-1,w-w i ] > B[i-1,w] B[i,w] = b i + B[i-1,w- w i ] else B[i,w] = B[i-1,w] else B[i,w] = B[i-1,w] // w i > w 0 0 0 0 0 0 W 0 1 2 3 4 5 i 0 1 2 3 0 0 0 0 i=2 b i =4 w i =3 w= 2 w-w i =-1 Items: 1: (2,3) 2: (3,4) 3: (4,5) 4: (5,6) 4 0 3 3 3 3 0 3
  • 29. Example (11) if w i <= w // item i can be part of the solution if b i + B[i-1,w-w i ] > B[i-1,w] B[i,w] = b i + B[i-1,w- w i ] else B[i,w] = B[i-1,w] else B[i,w] = B[i-1,w] // w i > w 0 0 0 0 0 0 W 0 1 2 3 4 5 i 0 1 2 3 0 0 0 0 i=2 b i =4 w i =3 w= 3 w-w i =0 Items: 1: (2,3) 2: (3,4) 3: (4,5) 4: (5,6) 4 0 3 3 3 3 0 3 4
  • 30. Example (12) if w i <= w // item i can be part of the solution if b i + B[i-1,w-w i ] > B[i-1,w] B[i,w] = b i + B[i-1,w- w i ] else B[i,w] = B[i-1,w] else B[i,w] = B[i-1,w] // w i > w 0 0 0 0 0 0 W 0 1 2 3 4 5 i 0 1 2 3 0 0 0 0 i=2 b i =4 w i =3 w= 4 w-w i =1 Items: 1: (2,3) 2: (3,4) 3: (4,5) 4: (5,6) 4 0 3 3 3 3 0 3 4 4
  • 31. Example (13) if w i <= w // item i can be part of the solution if b i + B[i-1,w-w i ] > B[i-1,w] B[i,w] = b i + B[i-1,w- w i ] else B[i,w] = B[i-1,w] else B[i,w] = B[i-1,w] // w i > w 0 0 0 0 0 0 W 0 1 2 3 4 5 i 0 1 2 3 0 0 0 0 i=2 b i =4 w i =3 w= 5 w-w i =2 Items: 1: (2,3) 2: (3,4) 3: (4,5) 4: (5,6) 4 0 3 3 3 3 0 3 4 4 7
  • 32. Example (14) if w i <= w // item i can be part of the solution if b i + B[i-1,w-w i ] > B[i-1,w] B[i,w] = b i + B[i-1,w- w i ] else B[i,w] = B[i-1,w] else B[i,w] = B[i-1,w] // w i > w 0 0 0 0 0 0 W 0 1 2 3 4 5 i 0 1 2 3 0 0 0 0 i=3 b i =5 w i =4 w= 1..3 Items: 1: (2,3) 2: (3,4) 3: (4,5) 4: (5,6) 4 0 3 3 3 3 0 0 3 4 4 7 0 3 4
  • 33. Example (15) if w i <= w // item i can be part of the solution if b i + B[i-1,w-w i ] > B[i-1,w] B[i,w] = b i + B[i-1,w- w i ] else B[i,w] = B[i-1,w] else B[i,w] = B[i-1,w] // w i > w 0 0 0 0 0 0 W 0 1 2 3 4 5 i 0 1 2 3 0 0 0 0 i=3 b i =5 w i =4 w= 4 w- w i =0 Items: 1: (2,3) 2: (3,4) 3: (4,5) 4: (5,6) 4 0 0 0 3 4 4 7 0 3 4 5 3 3 3 3
  • 34. Example (15) if w i <= w // item i can be part of the solution if b i + B[i-1,w-w i ] > B[i-1,w] B[i,w] = b i + B[i-1,w- w i ] else B[i,w] = B[i-1,w] else B[i,w] = B[i-1,w] // w i > w 0 0 0 0 0 0 W 0 1 2 3 4 5 i 0 1 2 3 0 0 0 0 i=3 b i =5 w i =4 w= 5 w- w i =1 Items: 1: (2,3) 2: (3,4) 3: (4,5) 4: (5,6) 4 0 0 0 3 4 4 7 0 3 4 5 7 3 3 3 3
  • 35. Example (16) if w i <= w // item i can be part of the solution if b i + B[i-1,w-w i ] > B[i-1,w] B[i,w] = b i + B[i-1,w- w i ] else B[i,w] = B[i-1,w] else B[i,w] = B[i-1,w] // w i > w 0 0 0 0 0 0 W 0 1 2 3 4 5 i 0 1 2 3 0 0 0 0 i=3 b i =5 w i =4 w= 1..4 Items: 1: (2,3) 2: (3,4) 3: (4,5) 4: (5,6) 4 0 0 0 3 4 4 7 0 3 4 5 7 0 3 4 5 3 3 3 3
  • 36. Example (17) if w i <= w // item i can be part of the solution if b i + B[i-1,w-w i ] > B[i-1,w] B[i,w] = b i + B[i-1,w- w i ] else B[i,w] = B[i-1,w] else B[i,w] = B[i-1,w] // w i > w 0 0 0 0 0 0 W 0 1 2 3 4 5 i 0 1 2 3 0 0 0 0 i=3 b i =5 w i =4 w= 5 Items: 1: (2,3) 2: (3,4) 3: (4,5) 4: (5,6) 4 0 0 0 3 4 4 7 0 3 4 5 7 0 3 4 5 7 3 3 3 3
  • 37.
  • 38.