SlideShare a Scribd company logo
1 of 14
Presented By
MD. Sad Adnan 162-15-7814
Quazi Zayed Bin Hasan 162-15-7695
Susmita karmakar 162-15-7721
Quazi Zayed Bin Hasan
162-15-7695
Length of pieces Profit for pieces
0 0
1 2 $
2 5 $
3 9 $
4 6 $
0 0 0 0 0 0
0 2 4 6 8 10
0 2 5 7 10 12
0 2 5 9 11 14
0 2 5 9 11 14
#If pieces of length is greater than the total length that’s why previous profit
and current profit are same
#If previous profit is greater than current profit that’s why we count previous
profit is the current profit
14
MD. Sad Adnan
162-15-7814
Pseudo Code
int priceOfLen[ ] = {0, 2, 5, 9, 6};
int maxProfit( n )
{
for (totalLen  1 to n)
{
tmp  0;
for (partLen  1 to totalLen)
{
thisProfit  priceOfLen[partLen] + maxProfitOfLen[totalLen - partLen];
if (tmp < thisProfit)
{
tmp  thisProfit;
partLenOfLen[totalLen]  partLen;
}
}
maxProfitOfLen[totalLen]  tmp;
}
return maxProfitOfLen[n];
}
Void Divisions( n )
{
while (n > 0)
{
print partLenOfLen[n] ;
n  n - partLenOfLen[n];
}
}
Pseudo Code For Knowing The How We Have To Cut The Rod
0 1 2 3 4 5
priceOfLen[ ]
maxProfitOfLen[ ]
partLenOfLen[ ]
n totalLen partLen
Temp
( start with 0)
thisProfit MaxProfit Division OF ROD
5
1 1 2 2 2 1
2
1 4 4
5
2
2 5 5
3
1 7 7
9
3
2 7 7
3 9 9
4
1 11 11
11
1
2 11 10 3
3 11 11
4 11 6
5
1 13 13
14
2
2 14 14 3
3 14 14
4 14 8
5 14 0
Susmita karmakar
162-15-7721
Time complexity
T(n) = T(n-1) + T(n-2) +…..+T(1) +
1T(1)=1T(2) = T(1) + 1= 2T(3) = T(2) + T(1)+
1 = 2 + 1 + 1 T(n) = n + n-1 + n-2 + … in an
Arithmetic ProgressionT(n) = O(n²)
The run time complexity is T(n)=O(n²).
Rod Cutting Problem

More Related Content

What's hot

All pairs shortest path algorithm
All pairs shortest path algorithmAll pairs shortest path algorithm
All pairs shortest path algorithm
Srikrishnan Suresh
 

What's hot (20)

Dynamic programming
Dynamic programmingDynamic programming
Dynamic programming
 
Bruteforce algorithm
Bruteforce algorithmBruteforce algorithm
Bruteforce algorithm
 
Shortest path algorithms
Shortest path algorithmsShortest path algorithms
Shortest path algorithms
 
All pairs shortest path algorithm
All pairs shortest path algorithmAll pairs shortest path algorithm
All pairs shortest path algorithm
 
Greedy algorithms
Greedy algorithmsGreedy algorithms
Greedy algorithms
 
Dfs
DfsDfs
Dfs
 
Knapsack Problem
Knapsack ProblemKnapsack Problem
Knapsack Problem
 
Greedy Algorithm - Knapsack Problem
Greedy Algorithm - Knapsack ProblemGreedy Algorithm - Knapsack Problem
Greedy Algorithm - Knapsack Problem
 
Dynamic pgmming
Dynamic pgmmingDynamic pgmming
Dynamic pgmming
 
Sum of subset problem.pptx
Sum of subset problem.pptxSum of subset problem.pptx
Sum of subset problem.pptx
 
Prim's Algorithm on minimum spanning tree
Prim's Algorithm on minimum spanning treePrim's Algorithm on minimum spanning tree
Prim's Algorithm on minimum spanning tree
 
Shortest Path in Graph
Shortest Path in GraphShortest Path in Graph
Shortest Path in Graph
 
01 Knapsack using Dynamic Programming
01 Knapsack using Dynamic Programming01 Knapsack using Dynamic Programming
01 Knapsack using Dynamic Programming
 
Projection Matrices
Projection MatricesProjection Matrices
Projection Matrices
 
Backtracking
BacktrackingBacktracking
Backtracking
 
Matrix multiplication
Matrix multiplicationMatrix multiplication
Matrix multiplication
 
Dijkstra
DijkstraDijkstra
Dijkstra
 
Branch and bounding : Data structures
Branch and bounding : Data structuresBranch and bounding : Data structures
Branch and bounding : Data structures
 
Dijkstra’S Algorithm
Dijkstra’S AlgorithmDijkstra’S Algorithm
Dijkstra’S Algorithm
 
Greedy Algorihm
Greedy AlgorihmGreedy Algorihm
Greedy Algorihm
 

Recently uploaded

21P35A0312 Internship eccccccReport.docx
21P35A0312 Internship eccccccReport.docx21P35A0312 Internship eccccccReport.docx
21P35A0312 Internship eccccccReport.docx
rahulmanepalli02
 
Artificial intelligence presentation2-171219131633.pdf
Artificial intelligence presentation2-171219131633.pdfArtificial intelligence presentation2-171219131633.pdf
Artificial intelligence presentation2-171219131633.pdf
Kira Dess
 
01-vogelsanger-stanag-4178-ed-2-the-new-nato-standard-for-nitrocellulose-test...
01-vogelsanger-stanag-4178-ed-2-the-new-nato-standard-for-nitrocellulose-test...01-vogelsanger-stanag-4178-ed-2-the-new-nato-standard-for-nitrocellulose-test...
01-vogelsanger-stanag-4178-ed-2-the-new-nato-standard-for-nitrocellulose-test...
AshwaniAnuragi1
 

Recently uploaded (20)

CLOUD COMPUTING SERVICES - Cloud Reference Modal
CLOUD COMPUTING SERVICES - Cloud Reference ModalCLOUD COMPUTING SERVICES - Cloud Reference Modal
CLOUD COMPUTING SERVICES - Cloud Reference Modal
 
Signal Processing and Linear System Analysis
Signal Processing and Linear System AnalysisSignal Processing and Linear System Analysis
Signal Processing and Linear System Analysis
 
5G and 6G refer to generations of mobile network technology, each representin...
5G and 6G refer to generations of mobile network technology, each representin...5G and 6G refer to generations of mobile network technology, each representin...
5G and 6G refer to generations of mobile network technology, each representin...
 
Adsorption (mass transfer operations 2) ppt
Adsorption (mass transfer operations 2) pptAdsorption (mass transfer operations 2) ppt
Adsorption (mass transfer operations 2) ppt
 
21P35A0312 Internship eccccccReport.docx
21P35A0312 Internship eccccccReport.docx21P35A0312 Internship eccccccReport.docx
21P35A0312 Internship eccccccReport.docx
 
Introduction-to- Metrology and Quality.pptx
Introduction-to- Metrology and Quality.pptxIntroduction-to- Metrology and Quality.pptx
Introduction-to- Metrology and Quality.pptx
 
Maximizing Incident Investigation Efficacy in Oil & Gas: Techniques and Tools
Maximizing Incident Investigation Efficacy in Oil & Gas: Techniques and ToolsMaximizing Incident Investigation Efficacy in Oil & Gas: Techniques and Tools
Maximizing Incident Investigation Efficacy in Oil & Gas: Techniques and Tools
 
8th International Conference on Soft Computing, Mathematics and Control (SMC ...
8th International Conference on Soft Computing, Mathematics and Control (SMC ...8th International Conference on Soft Computing, Mathematics and Control (SMC ...
8th International Conference on Soft Computing, Mathematics and Control (SMC ...
 
Artificial intelligence presentation2-171219131633.pdf
Artificial intelligence presentation2-171219131633.pdfArtificial intelligence presentation2-171219131633.pdf
Artificial intelligence presentation2-171219131633.pdf
 
NO1 Best Powerful Vashikaran Specialist Baba Vashikaran Specialist For Love V...
NO1 Best Powerful Vashikaran Specialist Baba Vashikaran Specialist For Love V...NO1 Best Powerful Vashikaran Specialist Baba Vashikaran Specialist For Love V...
NO1 Best Powerful Vashikaran Specialist Baba Vashikaran Specialist For Love V...
 
Autodesk Construction Cloud (Autodesk Build).pptx
Autodesk Construction Cloud (Autodesk Build).pptxAutodesk Construction Cloud (Autodesk Build).pptx
Autodesk Construction Cloud (Autodesk Build).pptx
 
Presentation on Slab, Beam, Column, and Foundation/Footing
Presentation on Slab,  Beam, Column, and Foundation/FootingPresentation on Slab,  Beam, Column, and Foundation/Footing
Presentation on Slab, Beam, Column, and Foundation/Footing
 
NEWLETTER FRANCE HELICES/ SDS SURFACE DRIVES - MAY 2024
NEWLETTER FRANCE HELICES/ SDS SURFACE DRIVES - MAY 2024NEWLETTER FRANCE HELICES/ SDS SURFACE DRIVES - MAY 2024
NEWLETTER FRANCE HELICES/ SDS SURFACE DRIVES - MAY 2024
 
litvinenko_Henry_Intrusion_Hong-Kong_2024.pdf
litvinenko_Henry_Intrusion_Hong-Kong_2024.pdflitvinenko_Henry_Intrusion_Hong-Kong_2024.pdf
litvinenko_Henry_Intrusion_Hong-Kong_2024.pdf
 
Max. shear stress theory-Maximum Shear Stress Theory ​ Maximum Distortional ...
Max. shear stress theory-Maximum Shear Stress Theory ​  Maximum Distortional ...Max. shear stress theory-Maximum Shear Stress Theory ​  Maximum Distortional ...
Max. shear stress theory-Maximum Shear Stress Theory ​ Maximum Distortional ...
 
History of Indian Railways - the story of Growth & Modernization
History of Indian Railways - the story of Growth & ModernizationHistory of Indian Railways - the story of Growth & Modernization
History of Indian Railways - the story of Growth & Modernization
 
01-vogelsanger-stanag-4178-ed-2-the-new-nato-standard-for-nitrocellulose-test...
01-vogelsanger-stanag-4178-ed-2-the-new-nato-standard-for-nitrocellulose-test...01-vogelsanger-stanag-4178-ed-2-the-new-nato-standard-for-nitrocellulose-test...
01-vogelsanger-stanag-4178-ed-2-the-new-nato-standard-for-nitrocellulose-test...
 
Databricks Generative AI Fundamentals .pdf
Databricks Generative AI Fundamentals  .pdfDatabricks Generative AI Fundamentals  .pdf
Databricks Generative AI Fundamentals .pdf
 
Worksharing and 3D Modeling with Revit.pptx
Worksharing and 3D Modeling with Revit.pptxWorksharing and 3D Modeling with Revit.pptx
Worksharing and 3D Modeling with Revit.pptx
 
handbook on reinforce concrete and detailing
handbook on reinforce concrete and detailinghandbook on reinforce concrete and detailing
handbook on reinforce concrete and detailing
 

Rod Cutting Problem

  • 1.
  • 2. Presented By MD. Sad Adnan 162-15-7814 Quazi Zayed Bin Hasan 162-15-7695 Susmita karmakar 162-15-7721
  • 3. Quazi Zayed Bin Hasan 162-15-7695
  • 4. Length of pieces Profit for pieces 0 0 1 2 $ 2 5 $ 3 9 $ 4 6 $
  • 5. 0 0 0 0 0 0 0 2 4 6 8 10 0 2 5 7 10 12 0 2 5 9 11 14 0 2 5 9 11 14 #If pieces of length is greater than the total length that’s why previous profit and current profit are same #If previous profit is greater than current profit that’s why we count previous profit is the current profit 14
  • 6.
  • 8. Pseudo Code int priceOfLen[ ] = {0, 2, 5, 9, 6}; int maxProfit( n ) { for (totalLen  1 to n) { tmp  0; for (partLen  1 to totalLen) { thisProfit  priceOfLen[partLen] + maxProfitOfLen[totalLen - partLen]; if (tmp < thisProfit) { tmp  thisProfit; partLenOfLen[totalLen]  partLen; } } maxProfitOfLen[totalLen]  tmp; } return maxProfitOfLen[n]; }
  • 9. Void Divisions( n ) { while (n > 0) { print partLenOfLen[n] ; n  n - partLenOfLen[n]; } } Pseudo Code For Knowing The How We Have To Cut The Rod 0 1 2 3 4 5 priceOfLen[ ] maxProfitOfLen[ ] partLenOfLen[ ]
  • 10. n totalLen partLen Temp ( start with 0) thisProfit MaxProfit Division OF ROD 5 1 1 2 2 2 1 2 1 4 4 5 2 2 5 5 3 1 7 7 9 3 2 7 7 3 9 9 4 1 11 11 11 1 2 11 10 3 3 11 11 4 11 6 5 1 13 13 14 2 2 14 14 3 3 14 14 4 14 8 5 14 0
  • 13. T(n) = T(n-1) + T(n-2) +…..+T(1) + 1T(1)=1T(2) = T(1) + 1= 2T(3) = T(2) + T(1)+ 1 = 2 + 1 + 1 T(n) = n + n-1 + n-2 + … in an Arithmetic ProgressionT(n) = O(n²) The run time complexity is T(n)=O(n²).