SlideShare uma empresa Scribd logo
1 de 24
Presented By : Subhradeep Mitra
Ankita Dutta
Debanjana Biswas
(Student of mca rajabazar sc college)
Contents
• Graph-coloring using Intelligent Backtracking
• Graph-coloring
• Hamiltonian-cycle
• Subset-sum problem
• N-Queen problem
• Backtracking
• Conclusion
BACKTRACKING
The principle idea of back-tracking is to
construct solutions as component at a time.
And then evaluate such partially
constructed solutions.
Backtracking [animation]
start ?
?
dead end
dead end
?
?
dead end
dead end
?
success!
dead end
Key Terms:
• State-space tree
• Root
• Components
• Promising & Non-promising
• Leaves
N-Queen Problem
Problem:- The problem is to place n queens on an
n-by-n chessboard so that no two
queens attack each other by being in
the same row, or in the same column, or
in the same diagonal.
Observation:- Case 1 : n=1
Case 2 : n=2
Case 3 : n=3
Case 4 : n=4
• Case 4: For example to explain the n-
Queen problem we Consider n=4 using a 4-
by-4 chessboard where 4-Queens have to be
placed in such a way so that no two queen
can attack each other.
4
3
2
1
4321
Q
Q
Q
Q
Q
Q
Q
Q
Q
Q
Q
Q
Q
Q
Q
Q
Q
Q
2
1
3
5
6
4
0
7
8
x x
xxx
x x
x
xxxx
xx
xxx
Q
Q
Q
Q
Queen-1
Queen-2
Queen-3
Queen-44
3
2
1
4321
Board for the four-queens problemFigure:-
• Using this above mechanism we can obtain two
solutions shown in the two consecutive figures:-
Q
Q
Q
Q
Queen-1
Queen-2
Queen-3
Queen-44
3
2
1
4321
Board for the four-queens problemFigure:-
• Subset-sum Problem: The problem is to find a subset of a given set
S = {s1, s2,- - -, sn} of ‘n’ positive integers
whose sum is equal to a given positive integer
‘d’.
• Example : For S = {3, 5, 6, 7} and d = 15, the solution is
shown below :-
Solution = {3, 5, 7}
Subset-sum Problem
• Observation : It is convenient to sort the set’s elements in
increasing order, S1 ≤ S2 ≤ ….. ≤ Sn. And each
set of solutions don’t need to be necessarily of
fixed size.
15 8
511
05
814 3
8
9
3
0
3
0
with 6
with 5
with 6
with 7
with 6
with 5
with 3
w/o 5
w/o 6
w/o 5
w/o 3
w/o 6
w/o 7
w/o 6
solution
14+7>15 3+7<159+7>15 11+7>15
0+6+7<15
5+7<15
8<15
7
0
3
5
6
Figure : Compete state-space tree of the backtracking algorithm applied to the instance S =
{3, 5, 6, 7} and d = 15 of the subset-sum problem. The number inside a node is the
sum of the elements already included in subsets represented by the node. The
inequality below a leaf indicates the reason for its termination.
x
xx xxx
x
This problem is concern about finding a
Hamiltonian circuit in a given graph.
Problem:
Hamiltonian Circuit Problem
Hamiltonian circuit is defined as a cycle
that passes to all the vertices of the
graph exactly once except the starting
and ending vertices that is the same
vertex.
Hamiltonian
circuit:
Figure: • (a) Graph.
• (b) State-space tree for finding a Hamiltonian circuit. The
numbers above the nodes of the tree indicate the order the order
in which nodes are generated.
For example consider the given graph
and evaluate the mechanism:-
(a)
(b)
Coloring a map
Problem:
Let G be a graph and m be a given positive integer. We want to
discover whether the nodes of G can be colored in such a way that
no two adjacent node have the same color yet only m colors are
used. This technique is broadly used in “map-coloring”; Four-color
map is the main objective.
Consider the following map and it can be easily decomposed
into the following planner graph beside it :
This map-coloring problem of the given map
can be solved from the planner graph, using
the mechanism of backtracking. The state-
space tree for this above map is shown below:
Four colors are chosen as
- Red, Green, Blue and
Yellow
Now the map can be
colored as shown here:-
(a) The principal states and territories of Australia. Coloring this map can
be viewed as a constraint satisfaction problem (CSP). The goal is to assign colors
to each region so that no neighboring regions have the same color. (b) The map-
coloring problem represented as a constraint graph.
Figure:
Artificial Intelligence
Constraints: C = {SA WA, SA NT, SA Q, SA NSW, SA V, WA NT,
NT Q, Q NSW , NSW V}
domain of each variable Di = {red, green, blue}
We are given the task of coloring each region either red,
green, or blue in such a way that no neighboring regions have
the same color. To formulate this as a CSP the following
assumptions are made:
Problem:
regions as, X = {WA, NT ,Q, NSW ,V,SA,T}
Observation:-
• Once we have chosen {SA = blue}, none of the five neighboring
variables can take on the value blue. So we have only 25 = 32
assignments to look at instead of 35= 243 assignments for the five
neighboring variables.
• Furthermore, we can see why the assignment is not a solution—we
see which variables violate a constraint—so we can focus attention
on the variables that matter.
Now the map can be colored as shown here:-
Conclusion
In conclusion, three things on behalf of backtracking need
to be said:-
• It is typically applied to difficult combinatorial problems
for which no efficient algorithm for finding, exact solutions
possibly exist.
• Backtracking solves each instances of a problem in an
acceptable amount of time.
• It generates all elements of the problem state.
Reference: Books:
• Anany Levitin Design and Analysis of
Algorithms (page 394-405)
• Computer Algorithms Horowitz and Sahani
(page 380-393)
•http://www.2shared.com/document/W1dBNI
GP/Stuart_Russell_and_Peter_Norvi.html
Thank You

Mais conteúdo relacionado

Mais procurados

Backtracking Algorithm.ppt
Backtracking Algorithm.pptBacktracking Algorithm.ppt
Backtracking Algorithm.pptSalmIbrahimIlyas
 
implementation of travelling salesman problem with complexity ppt
implementation of travelling salesman problem with complexity pptimplementation of travelling salesman problem with complexity ppt
implementation of travelling salesman problem with complexity pptAntaraBhattacharya12
 
AI 7 | Constraint Satisfaction Problem
AI 7 | Constraint Satisfaction ProblemAI 7 | Constraint Satisfaction Problem
AI 7 | Constraint Satisfaction ProblemMohammad Imam Hossain
 
data structures- back tracking
data structures- back trackingdata structures- back tracking
data structures- back trackingAbinaya B
 
Strassen's matrix multiplication
Strassen's matrix multiplicationStrassen's matrix multiplication
Strassen's matrix multiplicationMegha V
 
sutherland- Hodgeman Polygon clipping
sutherland- Hodgeman Polygon clippingsutherland- Hodgeman Polygon clipping
sutherland- Hodgeman Polygon clippingArvind Kumar
 
Algorithms Lecture 1: Introduction to Algorithms
Algorithms Lecture 1: Introduction to AlgorithmsAlgorithms Lecture 1: Introduction to Algorithms
Algorithms Lecture 1: Introduction to AlgorithmsMohamed Loey
 
Divide and Conquer - Part 1
Divide and Conquer - Part 1Divide and Conquer - Part 1
Divide and Conquer - Part 1Amrinder Arora
 
State Space Representation and Search
State Space Representation and SearchState Space Representation and Search
State Space Representation and SearchHitesh Mohapatra
 
Mathematical Analysis of Recursive Algorithm.
Mathematical Analysis of Recursive Algorithm.Mathematical Analysis of Recursive Algorithm.
Mathematical Analysis of Recursive Algorithm.mohanrathod18
 
DESIGN AND ANALYSIS OF ALGORITHMS
DESIGN AND ANALYSIS OF ALGORITHMSDESIGN AND ANALYSIS OF ALGORITHMS
DESIGN AND ANALYSIS OF ALGORITHMSGayathri Gaayu
 
State space search and Problem Solving techniques
State space search and Problem Solving techniquesState space search and Problem Solving techniques
State space search and Problem Solving techniquesKirti Verma
 
Hidden surface removal
Hidden surface removalHidden surface removal
Hidden surface removalPunyajoy Saha
 
01 knapsack using backtracking
01 knapsack using backtracking01 knapsack using backtracking
01 knapsack using backtrackingmandlapure
 

Mais procurados (20)

Graph colouring
Graph colouringGraph colouring
Graph colouring
 
Greedy Algorihm
Greedy AlgorihmGreedy Algorihm
Greedy Algorihm
 
Backtracking Algorithm.ppt
Backtracking Algorithm.pptBacktracking Algorithm.ppt
Backtracking Algorithm.ppt
 
implementation of travelling salesman problem with complexity ppt
implementation of travelling salesman problem with complexity pptimplementation of travelling salesman problem with complexity ppt
implementation of travelling salesman problem with complexity ppt
 
AI 7 | Constraint Satisfaction Problem
AI 7 | Constraint Satisfaction ProblemAI 7 | Constraint Satisfaction Problem
AI 7 | Constraint Satisfaction Problem
 
N queen problem
N queen problemN queen problem
N queen problem
 
String matching algorithms
String matching algorithmsString matching algorithms
String matching algorithms
 
Dynamic programming
Dynamic programmingDynamic programming
Dynamic programming
 
data structures- back tracking
data structures- back trackingdata structures- back tracking
data structures- back tracking
 
Strassen's matrix multiplication
Strassen's matrix multiplicationStrassen's matrix multiplication
Strassen's matrix multiplication
 
Hill climbing algorithm
Hill climbing algorithmHill climbing algorithm
Hill climbing algorithm
 
sutherland- Hodgeman Polygon clipping
sutherland- Hodgeman Polygon clippingsutherland- Hodgeman Polygon clipping
sutherland- Hodgeman Polygon clipping
 
Algorithms Lecture 1: Introduction to Algorithms
Algorithms Lecture 1: Introduction to AlgorithmsAlgorithms Lecture 1: Introduction to Algorithms
Algorithms Lecture 1: Introduction to Algorithms
 
Divide and Conquer - Part 1
Divide and Conquer - Part 1Divide and Conquer - Part 1
Divide and Conquer - Part 1
 
State Space Representation and Search
State Space Representation and SearchState Space Representation and Search
State Space Representation and Search
 
Mathematical Analysis of Recursive Algorithm.
Mathematical Analysis of Recursive Algorithm.Mathematical Analysis of Recursive Algorithm.
Mathematical Analysis of Recursive Algorithm.
 
DESIGN AND ANALYSIS OF ALGORITHMS
DESIGN AND ANALYSIS OF ALGORITHMSDESIGN AND ANALYSIS OF ALGORITHMS
DESIGN AND ANALYSIS OF ALGORITHMS
 
State space search and Problem Solving techniques
State space search and Problem Solving techniquesState space search and Problem Solving techniques
State space search and Problem Solving techniques
 
Hidden surface removal
Hidden surface removalHidden surface removal
Hidden surface removal
 
01 knapsack using backtracking
01 knapsack using backtracking01 knapsack using backtracking
01 knapsack using backtracking
 

Semelhante a Graph Coloring and Backtracking Algorithms Explained

bcfbedbf-6679-4d5d-b8a5-7d4c9c48dba4.pptx
bcfbedbf-6679-4d5d-b8a5-7d4c9c48dba4.pptxbcfbedbf-6679-4d5d-b8a5-7d4c9c48dba4.pptx
bcfbedbf-6679-4d5d-b8a5-7d4c9c48dba4.pptxB.T.L.I.T
 
Algorithm Performance For Chessboard Separation Problems
Algorithm Performance For Chessboard Separation ProblemsAlgorithm Performance For Chessboard Separation Problems
Algorithm Performance For Chessboard Separation ProblemsTina Gabel
 
Backtracking-N Queens Problem-Graph Coloring-Hamiltonian cycle
Backtracking-N Queens Problem-Graph Coloring-Hamiltonian cycleBacktracking-N Queens Problem-Graph Coloring-Hamiltonian cycle
Backtracking-N Queens Problem-Graph Coloring-Hamiltonian cyclevarun arora
 
Graphs in Data Structure
 Graphs in Data Structure Graphs in Data Structure
Graphs in Data Structurehafsa komal
 
MODULE_05-Matrix Decomposition.pptx
MODULE_05-Matrix Decomposition.pptxMODULE_05-Matrix Decomposition.pptx
MODULE_05-Matrix Decomposition.pptxAlokSingh205089
 
Lego like spheres and tori, enumeration and drawings
Lego like spheres and tori, enumeration and drawingsLego like spheres and tori, enumeration and drawings
Lego like spheres and tori, enumeration and drawingsMathieu Dutour Sikiric
 
Undecidable Problems and Approximation Algorithms
Undecidable Problems and Approximation AlgorithmsUndecidable Problems and Approximation Algorithms
Undecidable Problems and Approximation AlgorithmsMuthu Vinayagam
 
Undecidable Problems - COPING WITH THE LIMITATIONS OF ALGORITHM POWER
Undecidable Problems - COPING WITH THE LIMITATIONS OF ALGORITHM POWERUndecidable Problems - COPING WITH THE LIMITATIONS OF ALGORITHM POWER
Undecidable Problems - COPING WITH THE LIMITATIONS OF ALGORITHM POWERmuthukrishnavinayaga
 
Color Coding-Related Techniques
Color Coding-Related TechniquesColor Coding-Related Techniques
Color Coding-Related Techniquescseiitgn
 
Graph Theory,Graph Terminologies,Planar Graph & Graph Colouring
Graph Theory,Graph Terminologies,Planar Graph & Graph ColouringGraph Theory,Graph Terminologies,Planar Graph & Graph Colouring
Graph Theory,Graph Terminologies,Planar Graph & Graph ColouringSaurabh Kaushik
 
Digital control systems (dcs) lecture 18-19-20
Digital control systems (dcs) lecture 18-19-20Digital control systems (dcs) lecture 18-19-20
Digital control systems (dcs) lecture 18-19-20Ali Rind
 
Taller de Geometria
Taller de GeometriaTaller de Geometria
Taller de GeometriaSuly Vitonas
 
Maths Revision Notes - IGCSE
Maths Revision Notes - IGCSEMaths Revision Notes - IGCSE
Maths Revision Notes - IGCSERahul Jose
 
Data Analysis and Algorithms Lecture 1: Introduction
 Data Analysis and Algorithms Lecture 1: Introduction Data Analysis and Algorithms Lecture 1: Introduction
Data Analysis and Algorithms Lecture 1: IntroductionTayyabSattar5
 

Semelhante a Graph Coloring and Backtracking Algorithms Explained (20)

bcfbedbf-6679-4d5d-b8a5-7d4c9c48dba4.pptx
bcfbedbf-6679-4d5d-b8a5-7d4c9c48dba4.pptxbcfbedbf-6679-4d5d-b8a5-7d4c9c48dba4.pptx
bcfbedbf-6679-4d5d-b8a5-7d4c9c48dba4.pptx
 
Algorithm Performance For Chessboard Separation Problems
Algorithm Performance For Chessboard Separation ProblemsAlgorithm Performance For Chessboard Separation Problems
Algorithm Performance For Chessboard Separation Problems
 
Backtracking
BacktrackingBacktracking
Backtracking
 
Backtracking-N Queens Problem-Graph Coloring-Hamiltonian cycle
Backtracking-N Queens Problem-Graph Coloring-Hamiltonian cycleBacktracking-N Queens Problem-Graph Coloring-Hamiltonian cycle
Backtracking-N Queens Problem-Graph Coloring-Hamiltonian cycle
 
Graphs in Data Structure
 Graphs in Data Structure Graphs in Data Structure
Graphs in Data Structure
 
Math1
Math1Math1
Math1
 
MODULE_05-Matrix Decomposition.pptx
MODULE_05-Matrix Decomposition.pptxMODULE_05-Matrix Decomposition.pptx
MODULE_05-Matrix Decomposition.pptx
 
Stochastic Process Exam Help
Stochastic Process Exam HelpStochastic Process Exam Help
Stochastic Process Exam Help
 
Stochastic Process Assignment Help
Stochastic Process Assignment HelpStochastic Process Assignment Help
Stochastic Process Assignment Help
 
Lego like spheres and tori, enumeration and drawings
Lego like spheres and tori, enumeration and drawingsLego like spheres and tori, enumeration and drawings
Lego like spheres and tori, enumeration and drawings
 
Undecidable Problems and Approximation Algorithms
Undecidable Problems and Approximation AlgorithmsUndecidable Problems and Approximation Algorithms
Undecidable Problems and Approximation Algorithms
 
Lecture 7 (inequalities)
Lecture 7 (inequalities)Lecture 7 (inequalities)
Lecture 7 (inequalities)
 
Undecidable Problems - COPING WITH THE LIMITATIONS OF ALGORITHM POWER
Undecidable Problems - COPING WITH THE LIMITATIONS OF ALGORITHM POWERUndecidable Problems - COPING WITH THE LIMITATIONS OF ALGORITHM POWER
Undecidable Problems - COPING WITH THE LIMITATIONS OF ALGORITHM POWER
 
Ca 1.6
Ca 1.6Ca 1.6
Ca 1.6
 
Color Coding-Related Techniques
Color Coding-Related TechniquesColor Coding-Related Techniques
Color Coding-Related Techniques
 
Graph Theory,Graph Terminologies,Planar Graph & Graph Colouring
Graph Theory,Graph Terminologies,Planar Graph & Graph ColouringGraph Theory,Graph Terminologies,Planar Graph & Graph Colouring
Graph Theory,Graph Terminologies,Planar Graph & Graph Colouring
 
Digital control systems (dcs) lecture 18-19-20
Digital control systems (dcs) lecture 18-19-20Digital control systems (dcs) lecture 18-19-20
Digital control systems (dcs) lecture 18-19-20
 
Taller de Geometria
Taller de GeometriaTaller de Geometria
Taller de Geometria
 
Maths Revision Notes - IGCSE
Maths Revision Notes - IGCSEMaths Revision Notes - IGCSE
Maths Revision Notes - IGCSE
 
Data Analysis and Algorithms Lecture 1: Introduction
 Data Analysis and Algorithms Lecture 1: Introduction Data Analysis and Algorithms Lecture 1: Introduction
Data Analysis and Algorithms Lecture 1: Introduction
 

Mais de subhradeep mitra

Different Transmission Media
Different Transmission MediaDifferent Transmission Media
Different Transmission Mediasubhradeep mitra
 
Wireless body area network
Wireless body area network Wireless body area network
Wireless body area network subhradeep mitra
 
Wireless Body Area Networking
Wireless Body Area NetworkingWireless Body Area Networking
Wireless Body Area Networkingsubhradeep mitra
 
Different types of Symmetric key Cryptography
Different types of Symmetric key CryptographyDifferent types of Symmetric key Cryptography
Different types of Symmetric key Cryptographysubhradeep mitra
 
Automatic temperature control using 8085 microprocessor
Automatic temperature control using 8085 microprocessorAutomatic temperature control using 8085 microprocessor
Automatic temperature control using 8085 microprocessorsubhradeep mitra
 
crosstalk minimisation using vlsi
crosstalk minimisation using vlsicrosstalk minimisation using vlsi
crosstalk minimisation using vlsisubhradeep mitra
 

Mais de subhradeep mitra (12)

INTERNET TECHNOLOGY
INTERNET  TECHNOLOGYINTERNET  TECHNOLOGY
INTERNET TECHNOLOGY
 
Different Transmission Media
Different Transmission MediaDifferent Transmission Media
Different Transmission Media
 
Fifa world cup
Fifa world cupFifa world cup
Fifa world cup
 
West bengal-tourism
West bengal-tourismWest bengal-tourism
West bengal-tourism
 
Generation Of Computer
Generation Of ComputerGeneration Of Computer
Generation Of Computer
 
Students Profile
Students ProfileStudents Profile
Students Profile
 
GLOBAL INSURANCE PVT LTD.
GLOBAL INSURANCE PVT LTD.GLOBAL INSURANCE PVT LTD.
GLOBAL INSURANCE PVT LTD.
 
Wireless body area network
Wireless body area network Wireless body area network
Wireless body area network
 
Wireless Body Area Networking
Wireless Body Area NetworkingWireless Body Area Networking
Wireless Body Area Networking
 
Different types of Symmetric key Cryptography
Different types of Symmetric key CryptographyDifferent types of Symmetric key Cryptography
Different types of Symmetric key Cryptography
 
Automatic temperature control using 8085 microprocessor
Automatic temperature control using 8085 microprocessorAutomatic temperature control using 8085 microprocessor
Automatic temperature control using 8085 microprocessor
 
crosstalk minimisation using vlsi
crosstalk minimisation using vlsicrosstalk minimisation using vlsi
crosstalk minimisation using vlsi
 

Último

Activity 2-unit 2-update 2024. English translation
Activity 2-unit 2-update 2024. English translationActivity 2-unit 2-update 2024. English translation
Activity 2-unit 2-update 2024. English translationRosabel UA
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Mark Reed
 
Integumentary System SMP B. Pharm Sem I.ppt
Integumentary System SMP B. Pharm Sem I.pptIntegumentary System SMP B. Pharm Sem I.ppt
Integumentary System SMP B. Pharm Sem I.pptshraddhaparab530
 
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYKayeClaireEstoconing
 
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSGRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSJoshuaGantuangco2
 
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...JojoEDelaCruz
 
Active Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdfActive Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdfPatidar M
 
Transaction Management in Database Management System
Transaction Management in Database Management SystemTransaction Management in Database Management System
Transaction Management in Database Management SystemChristalin Nelson
 
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
 
4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptxmary850239
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parentsnavabharathschool99
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)lakshayb543
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17Celine George
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptxmary850239
 
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
 
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.
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...JhezDiaz1
 

Último (20)

Activity 2-unit 2-update 2024. English translation
Activity 2-unit 2-update 2024. English translationActivity 2-unit 2-update 2024. English translation
Activity 2-unit 2-update 2024. English translation
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)
 
Integumentary System SMP B. Pharm Sem I.ppt
Integumentary System SMP B. Pharm Sem I.pptIntegumentary System SMP B. Pharm Sem I.ppt
Integumentary System SMP B. Pharm Sem I.ppt
 
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptxLEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_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
 
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
 
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSGRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
 
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
 
Active Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdfActive Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdf
 
Transaction Management in Database Management System
Transaction Management in Database Management SystemTransaction Management in Database Management System
Transaction Management in Database Management System
 
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
 
4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parents
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.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
 
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
 
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...
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
 

Graph Coloring and Backtracking Algorithms Explained

  • 1. Presented By : Subhradeep Mitra Ankita Dutta Debanjana Biswas (Student of mca rajabazar sc college)
  • 2. Contents • Graph-coloring using Intelligent Backtracking • Graph-coloring • Hamiltonian-cycle • Subset-sum problem • N-Queen problem • Backtracking • Conclusion
  • 3. BACKTRACKING The principle idea of back-tracking is to construct solutions as component at a time. And then evaluate such partially constructed solutions.
  • 4. Backtracking [animation] start ? ? dead end dead end ? ? dead end dead end ? success! dead end
  • 5. Key Terms: • State-space tree • Root • Components • Promising & Non-promising • Leaves
  • 6. N-Queen Problem Problem:- The problem is to place n queens on an n-by-n chessboard so that no two queens attack each other by being in the same row, or in the same column, or in the same diagonal. Observation:- Case 1 : n=1 Case 2 : n=2 Case 3 : n=3 Case 4 : n=4
  • 7. • Case 4: For example to explain the n- Queen problem we Consider n=4 using a 4- by-4 chessboard where 4-Queens have to be placed in such a way so that no two queen can attack each other. 4 3 2 1 4321
  • 9. Q Q Q Q Queen-1 Queen-2 Queen-3 Queen-44 3 2 1 4321 Board for the four-queens problemFigure:- • Using this above mechanism we can obtain two solutions shown in the two consecutive figures:-
  • 11. • Subset-sum Problem: The problem is to find a subset of a given set S = {s1, s2,- - -, sn} of ‘n’ positive integers whose sum is equal to a given positive integer ‘d’. • Example : For S = {3, 5, 6, 7} and d = 15, the solution is shown below :- Solution = {3, 5, 7} Subset-sum Problem • Observation : It is convenient to sort the set’s elements in increasing order, S1 ≤ S2 ≤ ….. ≤ Sn. And each set of solutions don’t need to be necessarily of fixed size.
  • 12. 15 8 511 05 814 3 8 9 3 0 3 0 with 6 with 5 with 6 with 7 with 6 with 5 with 3 w/o 5 w/o 6 w/o 5 w/o 3 w/o 6 w/o 7 w/o 6 solution 14+7>15 3+7<159+7>15 11+7>15 0+6+7<15 5+7<15 8<15 7 0 3 5 6 Figure : Compete state-space tree of the backtracking algorithm applied to the instance S = {3, 5, 6, 7} and d = 15 of the subset-sum problem. The number inside a node is the sum of the elements already included in subsets represented by the node. The inequality below a leaf indicates the reason for its termination. x xx xxx x
  • 13. This problem is concern about finding a Hamiltonian circuit in a given graph. Problem: Hamiltonian Circuit Problem Hamiltonian circuit is defined as a cycle that passes to all the vertices of the graph exactly once except the starting and ending vertices that is the same vertex. Hamiltonian circuit:
  • 14. Figure: • (a) Graph. • (b) State-space tree for finding a Hamiltonian circuit. The numbers above the nodes of the tree indicate the order the order in which nodes are generated. For example consider the given graph and evaluate the mechanism:- (a) (b)
  • 15. Coloring a map Problem: Let G be a graph and m be a given positive integer. We want to discover whether the nodes of G can be colored in such a way that no two adjacent node have the same color yet only m colors are used. This technique is broadly used in “map-coloring”; Four-color map is the main objective. Consider the following map and it can be easily decomposed into the following planner graph beside it :
  • 16. This map-coloring problem of the given map can be solved from the planner graph, using the mechanism of backtracking. The state- space tree for this above map is shown below:
  • 17. Four colors are chosen as - Red, Green, Blue and Yellow Now the map can be colored as shown here:-
  • 18. (a) The principal states and territories of Australia. Coloring this map can be viewed as a constraint satisfaction problem (CSP). The goal is to assign colors to each region so that no neighboring regions have the same color. (b) The map- coloring problem represented as a constraint graph. Figure: Artificial Intelligence
  • 19. Constraints: C = {SA WA, SA NT, SA Q, SA NSW, SA V, WA NT, NT Q, Q NSW , NSW V} domain of each variable Di = {red, green, blue} We are given the task of coloring each region either red, green, or blue in such a way that no neighboring regions have the same color. To formulate this as a CSP the following assumptions are made: Problem: regions as, X = {WA, NT ,Q, NSW ,V,SA,T}
  • 20. Observation:- • Once we have chosen {SA = blue}, none of the five neighboring variables can take on the value blue. So we have only 25 = 32 assignments to look at instead of 35= 243 assignments for the five neighboring variables. • Furthermore, we can see why the assignment is not a solution—we see which variables violate a constraint—so we can focus attention on the variables that matter.
  • 21. Now the map can be colored as shown here:-
  • 22. Conclusion In conclusion, three things on behalf of backtracking need to be said:- • It is typically applied to difficult combinatorial problems for which no efficient algorithm for finding, exact solutions possibly exist. • Backtracking solves each instances of a problem in an acceptable amount of time. • It generates all elements of the problem state.
  • 23. Reference: Books: • Anany Levitin Design and Analysis of Algorithms (page 394-405) • Computer Algorithms Horowitz and Sahani (page 380-393) •http://www.2shared.com/document/W1dBNI GP/Stuart_Russell_and_Peter_Norvi.html