SlideShare a Scribd company logo
1 of 19
BACKTRACK SEARCH
ALGORITHM
BACKTRACKING
 Suppose you have to make a series of decisions,
among various choices, where
 You don’t have enough information to know what to
choose
 Each decision leads to a new set of choices
 Some sequence of choices (possibly more than one)
may be a solution to your problem
 Backtracking is a methodical way of trying out
various sequences of decisions, until you find the
correct one that “works”.
BACKTRACKING
 Backtracking is used to solve problems in which a
sequence of objects is chosen from a specified set
so that the sequence satisfies some criterion.
 Backtracking is a modified depth-first search of a
tree.
 It is the procedure whereby, after determining that a
node can lead to nothing but dead nodes, we go
back (“backtrack”) to the node’s parent and proceed
with the search on the next child.
BACKTRACK ALGORITHM
 Based on depth-first recursive search
 Approach
1. Tests whether solution has been found
2. If found solution, return it
3. Else for each choice that can be made
a) Make that choice
b) Recursive
c) If recursion returns a solution, return it
4. If no choices remain, return failure
 Some times called “search tree”
IMPROVING BACKTRACKING
 Search pruning will help us to reduce the search
space and hence get a solution faster.
 The idea is to avoid those paths that may not lead
to a solutions as early as possible by finding
contradictions so that we can backtrack
immediately without the need to build a hopeless
solution vector.
BACKTRACKING EXAMPLES
 The backtracking can be used in this cases:
Solving a maze
Coloring a map
Solving a puzzle
N queens problem etc.,
BACKTRACKING EXAMPLE—8 QUEENS
PROBLEM
 The 8-queens problem is a classical combinatorial
problem in which it is required to place eight
queens on an 8 x 8 chessboard so no two can
attack each other.
 A queen can attack another queen if it exists in the
same row, column or diagonal as the queen.
7
BACKTRACKING EXAMPLE—8 QUEENS
PROBLEM(CONT…)
 This problem can be solved by trying to place the
first queen, then the second queen so that it cannot
attack the first, and then the third so that it is not
conflicting with previously placed queens.
BACKTRACKING EXAMPLE—8 QUEENS
PROBLEM(CONT…)
 It is an empty 8 x 8
chess board. We have
to place the queens in
this board.
BACKTRACKING EXAMPLE—8 QUEENS
PROBLEM(CONT…)
 We have placed the
first queen on the
chess board
BACKTRACKING EXAMPLE—8 QUEENS
PROBLEM(CONT…)
 Then we have placed
the second queen on
the board.
 The darken place
should not have the
queens because they
are horizontal, vertical,
diagonal to the placed
queens.
BACKTRACKING EXAMPLE—8 QUEENS
PROBLEM(CONT…)
 We have placed the
third queen on board.
BACKTRACKING EXAMPLE—8 QUEENS
PROBLEM(CONT…)
 We have placed the 4th
queen on the board.
 We have placed that in
the wrong spot, so we
backtrack and change
the place of that one.
BACKTRACKING EXAMPLE—8 QUEENS
PROBLEM(CONT…)
 In this way, we have to
continue the process
untill our is reached ie.,
we must place 8
queens on the board.
BACKTRACKING EXAMPLE—8 QUEENS
PROBLEM(CONT…)
 Backtracking provides the hope to solve some
problem instances of nontrivial sizes by pruning
non-promising branches of the state-space tree.
 The success of backtracking varies from problem
to problem and from instance to instance.
 Backtracking possibly generates all possible
candidates in an exponentially growing state-
space tree.
PARALLELIZING BACKTRACK ALGORITHM
 First, we have to parallelize the root node of the
algorithm.
 Then the sub nodes and the child nodes should be
parallelized independently using the other
processors.
 For example, if we take the 8 queens problem then
it can be easily implemented in parallel.
 The N-queens problem can be parallelized in this
way.
PARALLELIZING BACKTRACK ALGORITHM
 The solutions to the n-queens problem can be
generated in parallel by using the master-worker
technique.
 The manager generates the upper portion of the
search tree by generating those nodes of fixed
depth d, for some d.
 The manager dynamically passes each of these
sequences to an idle worker, who in turn continues
to search for sequences with n-queens property
that contain the fixed subsequence of length d.
 The master-worker technique is particularly well-
suited for implementation with MPI
PARALLELIZING BACKTRACK ALGORITHM
 Parallelizing the backtrack algorithm will gives us a
good speedup and efficiency when compared to the
normal algorithm.
 The speedup and the efficiency will gets drastically
increased when it is done in the parallel.
THANK YOU!!!

More Related Content

Similar to Backtrack search-algorithm

Branch and bound
Branch and boundBranch and bound
Branch and boundAcad
 
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
 
module5_backtrackingnbranchnbound_2022.pdf
module5_backtrackingnbranchnbound_2022.pdfmodule5_backtrackingnbranchnbound_2022.pdf
module5_backtrackingnbranchnbound_2022.pdfShiwani Gupta
 
8 QUEENS PROBLEM.pptx
8 QUEENS PROBLEM.pptx8 QUEENS PROBLEM.pptx
8 QUEENS PROBLEM.pptxsunidhi740916
 
data structures- back tracking
data structures- back trackingdata structures- back tracking
data structures- back trackingAbinaya B
 
BackTracking Algorithm: Technique and Examples
BackTracking Algorithm: Technique and ExamplesBackTracking Algorithm: Technique and Examples
BackTracking Algorithm: Technique and ExamplesFahim Ferdous
 
5.5 back track
5.5 back track5.5 back track
5.5 back trackKrish_ver2
 
Backtracking Algorithm.pptx
Backtracking Algorithm.pptxBacktracking Algorithm.pptx
Backtracking Algorithm.pptxsangeeta194160
 
(Radhika) presentation on chapter 2 ai
(Radhika) presentation on chapter 2 ai(Radhika) presentation on chapter 2 ai
(Radhika) presentation on chapter 2 aiRadhika Srinivasan
 
Optimization problems
Optimization problemsOptimization problems
Optimization problemsRuchika Sinha
 
Parallel_Algorithms_In_Combinatorial_Optimization_Problems.ppt
Parallel_Algorithms_In_Combinatorial_Optimization_Problems.pptParallel_Algorithms_In_Combinatorial_Optimization_Problems.ppt
Parallel_Algorithms_In_Combinatorial_Optimization_Problems.pptdakccse
 
Equations and tilings
Equations and tilingsEquations and tilings
Equations and tilingsnavajomath
 
DAA UNIT-4 (1).pdf
DAA UNIT-4 (1).pdfDAA UNIT-4 (1).pdf
DAA UNIT-4 (1).pdfssuser1eba0d
 
Parallel_Algorithms_In_Combinatorial_Optimization_Problems.ppt
Parallel_Algorithms_In_Combinatorial_Optimization_Problems.pptParallel_Algorithms_In_Combinatorial_Optimization_Problems.ppt
Parallel_Algorithms_In_Combinatorial_Optimization_Problems.pptBinayakMukherjee4
 
Ap Power Point Chpt8
Ap Power Point Chpt8Ap Power Point Chpt8
Ap Power Point Chpt8dplunkett
 

Similar to Backtrack search-algorithm (20)

Branch and bound
Branch and boundBranch and bound
Branch and bound
 
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
 
module5_backtrackingnbranchnbound_2022.pdf
module5_backtrackingnbranchnbound_2022.pdfmodule5_backtrackingnbranchnbound_2022.pdf
module5_backtrackingnbranchnbound_2022.pdf
 
8 QUEENS PROBLEM.pptx
8 QUEENS PROBLEM.pptx8 QUEENS PROBLEM.pptx
8 QUEENS PROBLEM.pptx
 
data structures- back tracking
data structures- back trackingdata structures- back tracking
data structures- back tracking
 
Backtracking
BacktrackingBacktracking
Backtracking
 
BackTracking Algorithm: Technique and Examples
BackTracking Algorithm: Technique and ExamplesBackTracking Algorithm: Technique and Examples
BackTracking Algorithm: Technique and Examples
 
Back tracking
Back trackingBack tracking
Back tracking
 
N Queens problem
N Queens problemN Queens problem
N Queens problem
 
5.5 back track
5.5 back track5.5 back track
5.5 back track
 
Backtracking Algorithm.pptx
Backtracking Algorithm.pptxBacktracking Algorithm.pptx
Backtracking Algorithm.pptx
 
(Radhika) presentation on chapter 2 ai
(Radhika) presentation on chapter 2 ai(Radhika) presentation on chapter 2 ai
(Radhika) presentation on chapter 2 ai
 
Optimization problems
Optimization problemsOptimization problems
Optimization problems
 
Knapsack problem using fixed tuple
Knapsack problem using fixed tupleKnapsack problem using fixed tuple
Knapsack problem using fixed tuple
 
Parallel_Algorithms_In_Combinatorial_Optimization_Problems.ppt
Parallel_Algorithms_In_Combinatorial_Optimization_Problems.pptParallel_Algorithms_In_Combinatorial_Optimization_Problems.ppt
Parallel_Algorithms_In_Combinatorial_Optimization_Problems.ppt
 
Equations and tilings
Equations and tilingsEquations and tilings
Equations and tilings
 
DAA UNIT-4 (1).pdf
DAA UNIT-4 (1).pdfDAA UNIT-4 (1).pdf
DAA UNIT-4 (1).pdf
 
Parallel_Algorithms_In_Combinatorial_Optimization_Problems.ppt
Parallel_Algorithms_In_Combinatorial_Optimization_Problems.pptParallel_Algorithms_In_Combinatorial_Optimization_Problems.ppt
Parallel_Algorithms_In_Combinatorial_Optimization_Problems.ppt
 
Ap Power Point Chpt8
Ap Power Point Chpt8Ap Power Point Chpt8
Ap Power Point Chpt8
 
DAA-Module-5.pptx
DAA-Module-5.pptxDAA-Module-5.pptx
DAA-Module-5.pptx
 

More from Ruchika Sinha

Greedy Algorithms WITH Activity Selection Problem.ppt
Greedy Algorithms WITH Activity Selection Problem.pptGreedy Algorithms WITH Activity Selection Problem.ppt
Greedy Algorithms WITH Activity Selection Problem.pptRuchika Sinha
 
Greedy with Task Scheduling Algorithm.ppt
Greedy with Task Scheduling Algorithm.pptGreedy with Task Scheduling Algorithm.ppt
Greedy with Task Scheduling Algorithm.pptRuchika Sinha
 
Greedy Algorithms Huffman Coding.ppt
Greedy Algorithms  Huffman Coding.pptGreedy Algorithms  Huffman Coding.ppt
Greedy Algorithms Huffman Coding.pptRuchika Sinha
 
DynProg_Knapsack.ppt
DynProg_Knapsack.pptDynProg_Knapsack.ppt
DynProg_Knapsack.pptRuchika Sinha
 
Greedy with Task Scheduling Algorithm.ppt
Greedy with Task Scheduling Algorithm.pptGreedy with Task Scheduling Algorithm.ppt
Greedy with Task Scheduling Algorithm.pptRuchika Sinha
 
Installation of motherboard
Installation of motherboardInstallation of motherboard
Installation of motherboardRuchika Sinha
 
Bellman ford algorithm
Bellman ford algorithmBellman ford algorithm
Bellman ford algorithmRuchika Sinha
 
Software for encrypting and decrypting text file powerpointpresentation
Software for encrypting and decrypting text file powerpointpresentationSoftware for encrypting and decrypting text file powerpointpresentation
Software for encrypting and decrypting text file powerpointpresentationRuchika Sinha
 

More from Ruchika Sinha (20)

Greedy Algorithms WITH Activity Selection Problem.ppt
Greedy Algorithms WITH Activity Selection Problem.pptGreedy Algorithms WITH Activity Selection Problem.ppt
Greedy Algorithms WITH Activity Selection Problem.ppt
 
Greedy with Task Scheduling Algorithm.ppt
Greedy with Task Scheduling Algorithm.pptGreedy with Task Scheduling Algorithm.ppt
Greedy with Task Scheduling Algorithm.ppt
 
Greedy Algorithms Huffman Coding.ppt
Greedy Algorithms  Huffman Coding.pptGreedy Algorithms  Huffman Coding.ppt
Greedy Algorithms Huffman Coding.ppt
 
DynProg_Knapsack.ppt
DynProg_Knapsack.pptDynProg_Knapsack.ppt
DynProg_Knapsack.ppt
 
Dijkstra.ppt
Dijkstra.pptDijkstra.ppt
Dijkstra.ppt
 
Greedy with Task Scheduling Algorithm.ppt
Greedy with Task Scheduling Algorithm.pptGreedy with Task Scheduling Algorithm.ppt
Greedy with Task Scheduling Algorithm.ppt
 
Clipping
ClippingClipping
Clipping
 
Lec22 intel
Lec22 intelLec22 intel
Lec22 intel
 
Pc assembly
Pc assemblyPc assembly
Pc assembly
 
Casing
CasingCasing
Casing
 
Installation of motherboard
Installation of motherboardInstallation of motherboard
Installation of motherboard
 
Shortest path
Shortest pathShortest path
Shortest path
 
Bellman ford algorithm
Bellman ford algorithmBellman ford algorithm
Bellman ford algorithm
 
Python material
Python materialPython material
Python material
 
Python3
Python3Python3
Python3
 
Regular Grammar
Regular GrammarRegular Grammar
Regular Grammar
 
Software Teting
Software TetingSoftware Teting
Software Teting
 
XML
XMLXML
XML
 
Software for encrypting and decrypting text file powerpointpresentation
Software for encrypting and decrypting text file powerpointpresentationSoftware for encrypting and decrypting text file powerpointpresentation
Software for encrypting and decrypting text file powerpointpresentation
 
Type casting
Type castingType casting
Type casting
 

Recently uploaded

MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSSIVASHANKAR N
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Dr.Costas Sachpazis
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations120cr0395
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxupamatechverse
 
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Serviceranjana rawat
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile servicerehmti665
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024hassan khalil
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Christo Ananth
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...ranjana rawat
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVRajaP95
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Dr.Costas Sachpazis
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...ranjana rawat
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSCAESB
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxupamatechverse
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130Suhani Kapoor
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 

Recently uploaded (20)

MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptx
 
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile service
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINEDJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
 
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCRCall Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentation
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptx
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
 

Backtrack search-algorithm

  • 2. BACKTRACKING  Suppose you have to make a series of decisions, among various choices, where  You don’t have enough information to know what to choose  Each decision leads to a new set of choices  Some sequence of choices (possibly more than one) may be a solution to your problem  Backtracking is a methodical way of trying out various sequences of decisions, until you find the correct one that “works”.
  • 3. BACKTRACKING  Backtracking is used to solve problems in which a sequence of objects is chosen from a specified set so that the sequence satisfies some criterion.  Backtracking is a modified depth-first search of a tree.  It is the procedure whereby, after determining that a node can lead to nothing but dead nodes, we go back (“backtrack”) to the node’s parent and proceed with the search on the next child.
  • 4. BACKTRACK ALGORITHM  Based on depth-first recursive search  Approach 1. Tests whether solution has been found 2. If found solution, return it 3. Else for each choice that can be made a) Make that choice b) Recursive c) If recursion returns a solution, return it 4. If no choices remain, return failure  Some times called “search tree”
  • 5. IMPROVING BACKTRACKING  Search pruning will help us to reduce the search space and hence get a solution faster.  The idea is to avoid those paths that may not lead to a solutions as early as possible by finding contradictions so that we can backtrack immediately without the need to build a hopeless solution vector.
  • 6. BACKTRACKING EXAMPLES  The backtracking can be used in this cases: Solving a maze Coloring a map Solving a puzzle N queens problem etc.,
  • 7. BACKTRACKING EXAMPLE—8 QUEENS PROBLEM  The 8-queens problem is a classical combinatorial problem in which it is required to place eight queens on an 8 x 8 chessboard so no two can attack each other.  A queen can attack another queen if it exists in the same row, column or diagonal as the queen. 7
  • 8. BACKTRACKING EXAMPLE—8 QUEENS PROBLEM(CONT…)  This problem can be solved by trying to place the first queen, then the second queen so that it cannot attack the first, and then the third so that it is not conflicting with previously placed queens.
  • 9. BACKTRACKING EXAMPLE—8 QUEENS PROBLEM(CONT…)  It is an empty 8 x 8 chess board. We have to place the queens in this board.
  • 10. BACKTRACKING EXAMPLE—8 QUEENS PROBLEM(CONT…)  We have placed the first queen on the chess board
  • 11. BACKTRACKING EXAMPLE—8 QUEENS PROBLEM(CONT…)  Then we have placed the second queen on the board.  The darken place should not have the queens because they are horizontal, vertical, diagonal to the placed queens.
  • 12. BACKTRACKING EXAMPLE—8 QUEENS PROBLEM(CONT…)  We have placed the third queen on board.
  • 13. BACKTRACKING EXAMPLE—8 QUEENS PROBLEM(CONT…)  We have placed the 4th queen on the board.  We have placed that in the wrong spot, so we backtrack and change the place of that one.
  • 14. BACKTRACKING EXAMPLE—8 QUEENS PROBLEM(CONT…)  In this way, we have to continue the process untill our is reached ie., we must place 8 queens on the board.
  • 15. BACKTRACKING EXAMPLE—8 QUEENS PROBLEM(CONT…)  Backtracking provides the hope to solve some problem instances of nontrivial sizes by pruning non-promising branches of the state-space tree.  The success of backtracking varies from problem to problem and from instance to instance.  Backtracking possibly generates all possible candidates in an exponentially growing state- space tree.
  • 16. PARALLELIZING BACKTRACK ALGORITHM  First, we have to parallelize the root node of the algorithm.  Then the sub nodes and the child nodes should be parallelized independently using the other processors.  For example, if we take the 8 queens problem then it can be easily implemented in parallel.  The N-queens problem can be parallelized in this way.
  • 17. PARALLELIZING BACKTRACK ALGORITHM  The solutions to the n-queens problem can be generated in parallel by using the master-worker technique.  The manager generates the upper portion of the search tree by generating those nodes of fixed depth d, for some d.  The manager dynamically passes each of these sequences to an idle worker, who in turn continues to search for sequences with n-queens property that contain the fixed subsequence of length d.  The master-worker technique is particularly well- suited for implementation with MPI
  • 18. PARALLELIZING BACKTRACK ALGORITHM  Parallelizing the backtrack algorithm will gives us a good speedup and efficiency when compared to the normal algorithm.  The speedup and the efficiency will gets drastically increased when it is done in the parallel.