SlideShare una empresa de Scribd logo
1 de 22
Backtracking Technique ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Backtracking Technique ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Outline of Backtracking Approach ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],1 2 3 5 7 11 4 6 8 9 10
N-Queens Problem
N-Queens Problem ,[object Object],[object Object],[object Object],Q Q Q Q 1  2  3  4  5  6  7  8 1 2 3 4 5 6 7 8
N-Queens Problem: DFS ,[object Object]
N-Queens Problem: DFS (Same Col/Row x) ,[object Object],X 1 =1 X 2 =2 3 4 4 3 4 3 4 2 3 2 3 2 2 4 3 2 3 4 1 4 1 3 2 4 1 3 4 1 2 4 3 2 1 2 3 4 (x 1 , x 2 , x 3 , x 4 )=(2, 4, 1, 3) ,[object Object],[object Object],[object Object]
N-Queens Problem: Backtracking ,[object Object],[object Object],[object Object],[object Object],Q  (i, col(i)) Q  (k, col(k)) Q (i,col(i)) Q (k,col(k))
N-Queens Problem: Backtracking ,[object Object]
N-Queens Problem ,[object Object],[object Object],[object Object],[object Object],#Nodes Checked DFS   (n n )  #Nodes Checked DFS (same col/row X) (n!) #Nodes Checked Backtracking 341 19,173,961 9.73 ⅹ10 12 1.20ⅹ 10 16 24 40,320 4.79 ⅹ10 8 8.72ⅹ 10 10 61 15,721 1.01 ⅹ10 7 3.78ⅹ 10 8 4 8 12 14 n
Graph Coloring ,[object Object],[object Object],[object Object],[object Object],V 1 V 2 V 4 V 3 2-coloring  X 3-coloring  O
Graph Coloring ,[object Object],[object Object],[object Object],start 1 2 3 2 1 3 2 1 3 2 1 3 X X X X X
Hamiltonian Circuits Problem ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Hamiltonian Circuits Problem ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],HC : X (Eg) V 1 V 2 V 6 V 5 V 3 V 7 V 4 V 8 V 1 V 2 V 5 V 3 V 4
Sum-of-Subsets Problem ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],A w 1 w 2 w 3 w 2 w 3 w 3 w 3 O O O O O O O {w 1 ,w 2 }
Sum-of-Subsets Problem ,[object Object],[object Object],[object Object],[object Object],[object Object],ⅹ 12 7 3 9 7 8 13 4 0 0 3 3 0 4 5 0 0 4 5 5 6 0 0 0 0 ⅹ ⅹ :  0+5+6=11<13 ⅹ ⅹ : 9+6=15>13 ⅹ ⅹ w1=3 w2=4 w3=5 w4=6 0 4 3 7
0-1 Knapsack Problem ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],x 1 =1 x 2 =1 x 3 =1 x 4 =1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 0 1 1 1 1 1 x 2 =1
Branch-and-Bound ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Breadth First Search ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],BFS of a graph BFS of a tree 1 2 3 4 5 6 7 8 9 1 2 5 6 7 8 9 3 4 10 11 12 13 14 15
0-1 Knapsack Problem ,[object Object],[object Object],0 0 115 40 2 115 0 0 82 70 7 115 40 2 98 120 17 0 70 7 80 80 12 80 70 7 70 90 12 98 40 2 50 100 17 0 90 12 90 30 5 82 80 15 82 30 5 40 0 0 60 p1=40 ,  w1=2 p2=30 ,  w2=5 p3=50 ,  w3=10 p4=10 ,  w4=5
0-1 Knapsack Problem ,[object Object],[object Object],[object Object],0 0 115 40 2 115 0 0 82 70 7 115 40 2 98 120 17 0 70 7 80 80 12 80 70 7 70 90 12 98 40 2 50 100 17 0 90 12 90 30 5 82 80 15 82 30 5 40 0 0 60 p1=40 ,  w1=2 p2=30 ,  w2=5 p3=50 ,  w3=10 p4=10 ,  w4=5
0-1 Knapsack Problem ,[object Object],0 0 115 40 2 115 0 0 82 70 7 115 40 2 98 120 17 0 70 7 80 90 12 98 40 2 50 100 17 0 p1=40 ,  w1=2 p2=30 ,  w2=5 p3=50 ,  w3=10 p4=10 ,  w4=5 90 12 90

Más contenido relacionado

La actualidad más candente

20. Parallel Databases in DBMS
20. Parallel Databases in DBMS20. Parallel Databases in DBMS
20. Parallel Databases in DBMS
koolkampus
 
Sets and disjoint sets union123
Sets and disjoint sets union123Sets and disjoint sets union123
Sets and disjoint sets union123
Ankita Goyal
 
15. Transactions in DBMS
15. Transactions in DBMS15. Transactions in DBMS
15. Transactions in DBMS
koolkampus
 
B trees in Data Structure
B trees in Data StructureB trees in Data Structure
B trees in Data Structure
Anuj Modi
 

La actualidad más candente (20)

Knapsack Problem
Knapsack ProblemKnapsack Problem
Knapsack Problem
 
Directory structure
Directory structureDirectory structure
Directory structure
 
20. Parallel Databases in DBMS
20. Parallel Databases in DBMS20. Parallel Databases in DBMS
20. Parallel Databases in DBMS
 
program partitioning and scheduling IN Advanced Computer Architecture
program partitioning and scheduling  IN Advanced Computer Architectureprogram partitioning and scheduling  IN Advanced Computer Architecture
program partitioning and scheduling IN Advanced Computer Architecture
 
Amortized Analysis of Algorithms
Amortized Analysis of Algorithms Amortized Analysis of Algorithms
Amortized Analysis of Algorithms
 
15 puzzle problem using branch and bound
15 puzzle problem using branch and bound15 puzzle problem using branch and bound
15 puzzle problem using branch and bound
 
Backtracking Algorithm.ppt
Backtracking Algorithm.pptBacktracking Algorithm.ppt
Backtracking Algorithm.ppt
 
Sets and disjoint sets union123
Sets and disjoint sets union123Sets and disjoint sets union123
Sets and disjoint sets union123
 
Master method
Master method Master method
Master method
 
Concurrency Control in Database Management System
Concurrency Control in Database Management SystemConcurrency Control in Database Management System
Concurrency Control in Database Management System
 
Swap space management and protection in os
Swap space management and protection  in osSwap space management and protection  in os
Swap space management and protection in os
 
Analysis of algorithms
Analysis of algorithmsAnalysis of algorithms
Analysis of algorithms
 
15. Transactions in DBMS
15. Transactions in DBMS15. Transactions in DBMS
15. Transactions in DBMS
 
Backtracking
BacktrackingBacktracking
Backtracking
 
Branch and bound
Branch and boundBranch and bound
Branch and bound
 
sum of subset problem using Backtracking
sum of subset problem using Backtrackingsum of subset problem using Backtracking
sum of subset problem using Backtracking
 
Greedy Algorihm
Greedy AlgorihmGreedy Algorihm
Greedy Algorihm
 
Shadow paging
Shadow pagingShadow paging
Shadow paging
 
Elements of dynamic programming
Elements of dynamic programmingElements of dynamic programming
Elements of dynamic programming
 
B trees in Data Structure
B trees in Data StructureB trees in Data Structure
B trees in Data Structure
 

Destacado

0 1 knapsack problem using dynamic programming
0 1 knapsack problem using dynamic programming0 1 knapsack problem using dynamic programming
0 1 knapsack problem using dynamic programming
Maher Alshammari
 
DESIGN AND ANALYSIS OF ALGORITHMS
DESIGN AND ANALYSIS OF ALGORITHMSDESIGN AND ANALYSIS OF ALGORITHMS
DESIGN AND ANALYSIS OF ALGORITHMS
Gayathri Gaayu
 

Destacado (10)

Knapsack
KnapsackKnapsack
Knapsack
 
1 blind search
1 blind search1 blind search
1 blind search
 
Knapsack problem using dynamic programming
Knapsack problem using dynamic programmingKnapsack problem using dynamic programming
Knapsack problem using dynamic programming
 
0 1 knapsack problem using dynamic programming
0 1 knapsack problem using dynamic programming0 1 knapsack problem using dynamic programming
0 1 knapsack problem using dynamic programming
 
Kruskal Algorithm
Kruskal AlgorithmKruskal Algorithm
Kruskal Algorithm
 
Genetic Algorithm based Approach to solve Non-Fractional (0/1) Knapsack Optim...
Genetic Algorithm based Approach to solve Non-Fractional (0/1) Knapsack Optim...Genetic Algorithm based Approach to solve Non-Fractional (0/1) Knapsack Optim...
Genetic Algorithm based Approach to solve Non-Fractional (0/1) Knapsack Optim...
 
DESIGN AND ANALYSIS OF ALGORITHMS
DESIGN AND ANALYSIS OF ALGORITHMSDESIGN AND ANALYSIS OF ALGORITHMS
DESIGN AND ANALYSIS OF ALGORITHMS
 
Knapsack problem
Knapsack problemKnapsack problem
Knapsack problem
 
Greedy Algorithm - Knapsack Problem
Greedy Algorithm - Knapsack ProblemGreedy Algorithm - Knapsack Problem
Greedy Algorithm - Knapsack Problem
 
Knapsack problem using fixed tuple
Knapsack problem using fixed tupleKnapsack problem using fixed tuple
Knapsack problem using fixed tuple
 

Similar a 01 knapsack using backtracking

Divide-and-Conquer & Dynamic ProgrammingDivide-and-Conqu.docx
Divide-and-Conquer & Dynamic ProgrammingDivide-and-Conqu.docxDivide-and-Conquer & Dynamic ProgrammingDivide-and-Conqu.docx
Divide-and-Conquer & Dynamic ProgrammingDivide-and-Conqu.docx
jacksnathalie
 
Newton Raphson method for load flow analysis
Newton Raphson method for load flow analysisNewton Raphson method for load flow analysis
Newton Raphson method for load flow analysis
divyanshuprakashrock
 

Similar a 01 knapsack using backtracking (20)

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
 
Disjoint sets
Disjoint setsDisjoint sets
Disjoint sets
 
2018 MUMS Fall Course - Statistical Representation of Model Input (EDITED) - ...
2018 MUMS Fall Course - Statistical Representation of Model Input (EDITED) - ...2018 MUMS Fall Course - Statistical Representation of Model Input (EDITED) - ...
2018 MUMS Fall Course - Statistical Representation of Model Input (EDITED) - ...
 
CS 354 Graphics Math
CS 354 Graphics MathCS 354 Graphics Math
CS 354 Graphics Math
 
Recursion - Computer Algorithms
Recursion - Computer AlgorithmsRecursion - Computer Algorithms
Recursion - Computer Algorithms
 
Dynamic Programming.pptx
Dynamic Programming.pptxDynamic Programming.pptx
Dynamic Programming.pptx
 
Divide-and-Conquer & Dynamic ProgrammingDivide-and-Conqu.docx
Divide-and-Conquer & Dynamic ProgrammingDivide-and-Conqu.docxDivide-and-Conquer & Dynamic ProgrammingDivide-and-Conqu.docx
Divide-and-Conquer & Dynamic ProgrammingDivide-and-Conqu.docx
 
Mathematics 9 Quadratic Functions (Module 1)
Mathematics 9 Quadratic Functions (Module 1)Mathematics 9 Quadratic Functions (Module 1)
Mathematics 9 Quadratic Functions (Module 1)
 
Backtracking
BacktrackingBacktracking
Backtracking
 
Integer_Functions .pdf
Integer_Functions .pdfInteger_Functions .pdf
Integer_Functions .pdf
 
Fast parallelizable scenario-based stochastic optimization
Fast parallelizable scenario-based stochastic optimizationFast parallelizable scenario-based stochastic optimization
Fast parallelizable scenario-based stochastic optimization
 
Module 1 quadratic functions
Module 1   quadratic functionsModule 1   quadratic functions
Module 1 quadratic functions
 
AOA ppt.ppt
AOA ppt.pptAOA ppt.ppt
AOA ppt.ppt
 
Bellman ford
Bellman fordBellman ford
Bellman ford
 
designanalysisalgorithm_unit-v-part2.pptx
designanalysisalgorithm_unit-v-part2.pptxdesignanalysisalgorithm_unit-v-part2.pptx
designanalysisalgorithm_unit-v-part2.pptx
 
Newton Raphson method for load flow analysis
Newton Raphson method for load flow analysisNewton Raphson method for load flow analysis
Newton Raphson method for load flow analysis
 
Daa chpater14
Daa chpater14Daa chpater14
Daa chpater14
 
Polynomials and Curve Fitting in MATLAB
Polynomials and Curve Fitting in MATLABPolynomials and Curve Fitting in MATLAB
Polynomials and Curve Fitting in MATLAB
 
Maths04
Maths04Maths04
Maths04
 
Chapter 04 answers
Chapter 04 answersChapter 04 answers
Chapter 04 answers
 

Último

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Último (20)

Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 

01 knapsack using backtracking

  • 1.
  • 2.
  • 3.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.