SlideShare a Scribd company logo
1 of 10
Traveling salesman
What are the differences between 'Backtracking'
and 'Branch & Bound' Algorithm techniques?
Backtracking
[1] It is used to find all possible
solutions available to the problem.
[2] It traverse tree by DFS (Depth First
Search).
[3] It realizes that it has made a bad
choice & undoes the last choice by
backing up.
[4] It search the state space tree until it
found a solution.
[5] It involves feasibility function
Branch-and-Bound
[1] It is used to solve optimization problem.
[2] It may traverse the tree in any manner,
DFS or BFS.
[3] It realizes that it already has a better
optimal solution that the pre-solution leads to
so it abandons that pre-solution.
[4] It completely searches the state space tree
to get optimal solution.
[5] It involves bounding function.
Here is the state space tree for n=4 (Using Branch And Bound)
What is traveling salesman problem?
• Let us look at a situation that there are 5 cities,
which are represented as NODES.
• There is a Person at NODE-1
• This person has to reach each nodes one and only
ones and come back to original (starting) position
• This process has to occur with minimum cost or
minimum distance travelled.
• Note that starting point can start with any Node. For
Example:
1-2-4-5-3-1
1-5-2-3-4-1
How to compute the cost of each node?
• A row/column is said to be reduce iff it contains at least one zero and
all remaining entries are non-negative.
• A matrix is reduced iff every row and column is reduced.
Rules of reduced cost matrix :
1. Change all entries in row i and column j from A to inf
2. Set A[j,1] to inf
3. Reduce all rows and columns in the resulting except for rows and
column containing only inf.
4. Cost Function C(s)=C(R)+A[i,j]+ r [r – total reduce value]
-10
-2
-2
-3
-4
REDUCTION (ROW)
INF 20 30 10 11
15 INF 16 4 2
3 5 INF 2 4
19 6 18 INF 3
16 4 7 16 INF
-1 -3
COLUMN REDUCTION
TOTAL REDUCTION = (10+2+2+3+4)+(1+3)
= 25
INF 10 17 0 1
12 INF 11 2 0
1 3 INF 0 2
15 3 12 INF 0
11 0 3 12 INF
INF 10 17 0 1
12 INF 11 2 0
0 3 INF 0 2
15 3 12 INF 0
11 0 0 12 INF
Thank you all…….

More Related Content

What's hot

BackTracking Algorithm: Technique and Examples
BackTracking Algorithm: Technique and ExamplesBackTracking Algorithm: Technique and Examples
BackTracking Algorithm: Technique and ExamplesFahim Ferdous
 
Knapsack problem using greedy approach
Knapsack problem using greedy approachKnapsack problem using greedy approach
Knapsack problem using greedy approachpadmeshagrekar
 
Traveling salesman problem
Traveling salesman problemTraveling salesman problem
Traveling salesman problemJayesh Chauhan
 
The n Queen Problem
The n Queen ProblemThe n Queen Problem
The n Queen ProblemSukrit Gupta
 
Water jug problem ai part 6
Water jug problem ai part 6Water jug problem ai part 6
Water jug problem ai part 6Kirti Verma
 
Os lab file c programs
Os lab file c programsOs lab file c programs
Os lab file c programsKandarp Tiwari
 
Performance analysis(Time & Space Complexity)
Performance analysis(Time & Space Complexity)Performance analysis(Time & Space Complexity)
Performance analysis(Time & Space Complexity)swapnac12
 
State space search
State space searchState space search
State space searchchauhankapil
 
Intermediate code generation (Compiler Design)
Intermediate code generation (Compiler Design)   Intermediate code generation (Compiler Design)
Intermediate code generation (Compiler Design) Tasif Tanzim
 

What's hot (20)

Dijkstra's Algorithm
Dijkstra's Algorithm Dijkstra's Algorithm
Dijkstra's Algorithm
 
BackTracking Algorithm: Technique and Examples
BackTracking Algorithm: Technique and ExamplesBackTracking Algorithm: Technique and Examples
BackTracking Algorithm: Technique and Examples
 
Knapsack problem using greedy approach
Knapsack problem using greedy approachKnapsack problem using greedy approach
Knapsack problem using greedy approach
 
Bfs and Dfs
Bfs and DfsBfs and Dfs
Bfs and Dfs
 
Dynamic programming
Dynamic programmingDynamic programming
Dynamic programming
 
Traveling salesman problem
Traveling salesman problemTraveling salesman problem
Traveling salesman problem
 
Tsp branch and-bound
Tsp branch and-boundTsp branch and-bound
Tsp branch and-bound
 
The n Queen Problem
The n Queen ProblemThe n Queen Problem
The n Queen Problem
 
Water jug problem ai part 6
Water jug problem ai part 6Water jug problem ai part 6
Water jug problem ai part 6
 
Np cooks theorem
Np cooks theoremNp cooks theorem
Np cooks theorem
 
Greedy Algorithms
Greedy AlgorithmsGreedy Algorithms
Greedy Algorithms
 
Os lab file c programs
Os lab file c programsOs lab file c programs
Os lab file c programs
 
Performance analysis(Time & Space Complexity)
Performance analysis(Time & Space Complexity)Performance analysis(Time & Space Complexity)
Performance analysis(Time & Space Complexity)
 
State space search
State space searchState space search
State space search
 
Semaphores
SemaphoresSemaphores
Semaphores
 
Intermediate code generation (Compiler Design)
Intermediate code generation (Compiler Design)   Intermediate code generation (Compiler Design)
Intermediate code generation (Compiler Design)
 
Tsp is NP-Complete
Tsp is NP-CompleteTsp is NP-Complete
Tsp is NP-Complete
 
NP completeness
NP completenessNP completeness
NP completeness
 
Regular expressions
Regular expressionsRegular expressions
Regular expressions
 
Code generation
Code generationCode generation
Code generation
 

Viewers also liked

Travelling Salesperson Problem-Branch & Bound
Travelling Salesperson Problem-Branch & BoundTravelling Salesperson Problem-Branch & Bound
Travelling Salesperson Problem-Branch & BoundSharmilaChidaravalli
 
Branch and bounding : Data structures
Branch and bounding : Data structuresBranch and bounding : Data structures
Branch and bounding : Data structuresKàŕtheek Jåvvàjí
 
Branch and bound technique
Branch and bound techniqueBranch and bound technique
Branch and bound techniqueishmecse13
 
Branch and bound technique
Branch and bound techniqueBranch and bound technique
Branch and bound techniqueishmecse13
 
Back tracking and branch and bound class 20
Back tracking and branch and bound class 20Back tracking and branch and bound class 20
Back tracking and branch and bound class 20Kumar
 
8 queens problem using back tracking
8 queens problem using back tracking8 queens problem using back tracking
8 queens problem using back trackingTech_MX
 

Viewers also liked (10)

Travelling Salesperson Problem-Branch & Bound
Travelling Salesperson Problem-Branch & BoundTravelling Salesperson Problem-Branch & Bound
Travelling Salesperson Problem-Branch & Bound
 
Branch&bound at
Branch&bound atBranch&bound at
Branch&bound at
 
Branch and bound
Branch and boundBranch and bound
Branch and bound
 
Branch & bound
Branch & boundBranch & bound
Branch & bound
 
Branch and bound
Branch and boundBranch and bound
Branch and bound
 
Branch and bounding : Data structures
Branch and bounding : Data structuresBranch and bounding : Data structures
Branch and bounding : Data structures
 
Branch and bound technique
Branch and bound techniqueBranch and bound technique
Branch and bound technique
 
Branch and bound technique
Branch and bound techniqueBranch and bound technique
Branch and bound technique
 
Back tracking and branch and bound class 20
Back tracking and branch and bound class 20Back tracking and branch and bound class 20
Back tracking and branch and bound class 20
 
8 queens problem using back tracking
8 queens problem using back tracking8 queens problem using back tracking
8 queens problem using back tracking
 

Similar to Travelling Salesman

designanalysisalgorithm_unit-v-part2.pptx
designanalysisalgorithm_unit-v-part2.pptxdesignanalysisalgorithm_unit-v-part2.pptx
designanalysisalgorithm_unit-v-part2.pptxarifimad15
 
Data structure - traveling sales person and mesh algorithm
Data structure - traveling sales person and mesh algorithmData structure - traveling sales person and mesh algorithm
Data structure - traveling sales person and mesh algorithmlavanya marichamy
 
Search algorithms for discrete optimization
Search algorithms for discrete optimizationSearch algorithms for discrete optimization
Search algorithms for discrete optimizationSally Salem
 
Sure interview algorithm-1103
Sure interview algorithm-1103Sure interview algorithm-1103
Sure interview algorithm-1103Sure Interview
 
Data Structure Marge sort Group 5 pptx so
Data Structure Marge sort Group 5 pptx soData Structure Marge sort Group 5 pptx so
Data Structure Marge sort Group 5 pptx soSalma368452
 
Cs1123 4 variables_constants
Cs1123 4 variables_constantsCs1123 4 variables_constants
Cs1123 4 variables_constantsTAlha MAlik
 
Exploring Algorithms
Exploring AlgorithmsExploring Algorithms
Exploring AlgorithmsSri Prasanna
 
Performance Analysis of OFDM Transceiver with Folded FFT and LMS Filter
Performance Analysis of OFDM Transceiver with Folded FFT and LMS FilterPerformance Analysis of OFDM Transceiver with Folded FFT and LMS Filter
Performance Analysis of OFDM Transceiver with Folded FFT and LMS Filteridescitation
 
Linear Programing.pptx
Linear Programing.pptxLinear Programing.pptx
Linear Programing.pptxAdnanHaleem
 
Framework for Extensible, Asynchronous Task Scheduling (FEATS) in Fortran
Framework for Extensible, Asynchronous Task Scheduling (FEATS) in FortranFramework for Extensible, Asynchronous Task Scheduling (FEATS) in Fortran
Framework for Extensible, Asynchronous Task Scheduling (FEATS) in FortranPatrick Diehl
 
Control Flow Graphs
Control Flow GraphsControl Flow Graphs
Control Flow Graphsdaimk2020
 
Control Flow Graphs
Control Flow GraphsControl Flow Graphs
Control Flow Graphsdaimk2020
 
INFORMATIVE ESSAYThe purpose of the Informative Essay assignme.docx
INFORMATIVE ESSAYThe purpose of the Informative Essay assignme.docxINFORMATIVE ESSAYThe purpose of the Informative Essay assignme.docx
INFORMATIVE ESSAYThe purpose of the Informative Essay assignme.docxcarliotwaycave
 
qadm-ppt-150918102124-lva1-app6892.pdf
qadm-ppt-150918102124-lva1-app6892.pdfqadm-ppt-150918102124-lva1-app6892.pdf
qadm-ppt-150918102124-lva1-app6892.pdfHari31856
 

Similar to Travelling Salesman (20)

Skyline queries
Skyline queriesSkyline queries
Skyline queries
 
Branch and Bound.pptx
Branch and Bound.pptxBranch and Bound.pptx
Branch and Bound.pptx
 
designanalysisalgorithm_unit-v-part2.pptx
designanalysisalgorithm_unit-v-part2.pptxdesignanalysisalgorithm_unit-v-part2.pptx
designanalysisalgorithm_unit-v-part2.pptx
 
Data structure - traveling sales person and mesh algorithm
Data structure - traveling sales person and mesh algorithmData structure - traveling sales person and mesh algorithm
Data structure - traveling sales person and mesh algorithm
 
Search algorithms for discrete optimization
Search algorithms for discrete optimizationSearch algorithms for discrete optimization
Search algorithms for discrete optimization
 
Sure interview algorithm-1103
Sure interview algorithm-1103Sure interview algorithm-1103
Sure interview algorithm-1103
 
Data Structure Marge sort Group 5 pptx so
Data Structure Marge sort Group 5 pptx soData Structure Marge sort Group 5 pptx so
Data Structure Marge sort Group 5 pptx so
 
Cs1123 4 variables_constants
Cs1123 4 variables_constantsCs1123 4 variables_constants
Cs1123 4 variables_constants
 
Exploring Algorithms
Exploring AlgorithmsExploring Algorithms
Exploring Algorithms
 
Performance Analysis of OFDM Transceiver with Folded FFT and LMS Filter
Performance Analysis of OFDM Transceiver with Folded FFT and LMS FilterPerformance Analysis of OFDM Transceiver with Folded FFT and LMS Filter
Performance Analysis of OFDM Transceiver with Folded FFT and LMS Filter
 
Programming in c by pkv
Programming in c by pkvProgramming in c by pkv
Programming in c by pkv
 
Programming
ProgrammingProgramming
Programming
 
Linear Programing.pptx
Linear Programing.pptxLinear Programing.pptx
Linear Programing.pptx
 
Framework for Extensible, Asynchronous Task Scheduling (FEATS) in Fortran
Framework for Extensible, Asynchronous Task Scheduling (FEATS) in FortranFramework for Extensible, Asynchronous Task Scheduling (FEATS) in Fortran
Framework for Extensible, Asynchronous Task Scheduling (FEATS) in Fortran
 
Control Flow Graphs
Control Flow GraphsControl Flow Graphs
Control Flow Graphs
 
Control Flow Graphs
Control Flow GraphsControl Flow Graphs
Control Flow Graphs
 
Team 4
Team 4Team 4
Team 4
 
INFORMATIVE ESSAYThe purpose of the Informative Essay assignme.docx
INFORMATIVE ESSAYThe purpose of the Informative Essay assignme.docxINFORMATIVE ESSAYThe purpose of the Informative Essay assignme.docx
INFORMATIVE ESSAYThe purpose of the Informative Essay assignme.docx
 
Assignment Problem
Assignment ProblemAssignment Problem
Assignment Problem
 
qadm-ppt-150918102124-lva1-app6892.pdf
qadm-ppt-150918102124-lva1-app6892.pdfqadm-ppt-150918102124-lva1-app6892.pdf
qadm-ppt-150918102124-lva1-app6892.pdf
 

Travelling Salesman

  • 2. What are the differences between 'Backtracking' and 'Branch & Bound' Algorithm techniques? Backtracking [1] It is used to find all possible solutions available to the problem. [2] It traverse tree by DFS (Depth First Search). [3] It realizes that it has made a bad choice & undoes the last choice by backing up. [4] It search the state space tree until it found a solution. [5] It involves feasibility function Branch-and-Bound [1] It is used to solve optimization problem. [2] It may traverse the tree in any manner, DFS or BFS. [3] It realizes that it already has a better optimal solution that the pre-solution leads to so it abandons that pre-solution. [4] It completely searches the state space tree to get optimal solution. [5] It involves bounding function.
  • 3. Here is the state space tree for n=4 (Using Branch And Bound)
  • 4. What is traveling salesman problem? • Let us look at a situation that there are 5 cities, which are represented as NODES. • There is a Person at NODE-1 • This person has to reach each nodes one and only ones and come back to original (starting) position • This process has to occur with minimum cost or minimum distance travelled. • Note that starting point can start with any Node. For Example: 1-2-4-5-3-1 1-5-2-3-4-1
  • 5. How to compute the cost of each node? • A row/column is said to be reduce iff it contains at least one zero and all remaining entries are non-negative. • A matrix is reduced iff every row and column is reduced. Rules of reduced cost matrix : 1. Change all entries in row i and column j from A to inf 2. Set A[j,1] to inf 3. Reduce all rows and columns in the resulting except for rows and column containing only inf. 4. Cost Function C(s)=C(R)+A[i,j]+ r [r – total reduce value]
  • 6. -10 -2 -2 -3 -4 REDUCTION (ROW) INF 20 30 10 11 15 INF 16 4 2 3 5 INF 2 4 19 6 18 INF 3 16 4 7 16 INF -1 -3 COLUMN REDUCTION TOTAL REDUCTION = (10+2+2+3+4)+(1+3) = 25 INF 10 17 0 1 12 INF 11 2 0 1 3 INF 0 2 15 3 12 INF 0 11 0 3 12 INF INF 10 17 0 1 12 INF 11 2 0 0 3 INF 0 2 15 3 12 INF 0 11 0 0 12 INF
  • 7.
  • 8.
  • 9.