SlideShare a Scribd company logo
* Back tracking : The General Method
* The 8-Queens Problem
*Sum Of Subsets
* Graph Coloring
 Backtracking represents one of the most general
techniques. Many problems which deal with searching
for a set solutions or which ask for an optimal solution
satisfying some constraints can be solved using
backtracking formulation.
 In many applications of the backtrack method the
desired solution is expressible as an n-tuple
(x1,……,xn), Where the xi are chosen from some finite
set Si.
 For example , Consider the sudoko solving problem, We
try filling digits one by one. Whenever we find that current
digit cannot lead to a solution, We remove it (backtrack)
 And try next digit. This is better than naïve approach (
generating all possible combination of digits and the trying
every combination one by one) as it drops a set of
permutations whenever it backtracks.
 The 8-queens problem via a backtracking solution. In
fact we trivially generalize the problem and consider
an n*n chess board and try to find all ways to place n
nonattacking queens.
 Imagine the chessboard squares being numbered as
the indices of the two-dimensional array a[1:n,1:n],
then we observe that every element on the same
diagonal that runs from the upper left to the lower
right has the same row-column value.
 i – j = k – l (or) i + j = k – l
 The first equation implies
 j – l = i – k
 The second equation implies
 j – l = k – i
 Sum of subsets problem is to find subset of elements
that are selected from a given set whose sum adds up
to a given number k. We are considering the set
contains non-negative values. It is assumed that the
input set is unique (no duplicates are presented ).
 One way to find subsets that sum to K is to consider all
possible subsets. A Power set contains all those
subsets.
 Assume given set of 4 elements, say W[1]….W[4]. Tree
diagrams can be used to design backtracking algorithms .
The following tree diagram depicts approach of
generating variable sized tuple.
 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 nodes have
the same color yet only m colors are used. This is
termed the m – colorability decision problem. The d
is the degree of the given graph, then it can be colored
with d+1 colors. The m-colorability optimization
problems asks for the smallest integer m for which the
graph G can be colored.
 This integer is referred to as the chromatic number of
the graph. For example, the graph can be colored with
three colors 1,2, and3 . The color of each node is indicated
next to it. It can also be seen that three colors are needed
to color this graph and hence this graph’s chromatic
number 3.

More Related Content

What's hot

Graphing linear equations
Graphing linear equationsGraphing linear equations
Graphing linear equations
mathisthenewcool
 
Graph Theory
Graph TheoryGraph Theory
Graph Theory
Prateek Pandey
 
Backtracking
BacktrackingBacktracking
Backtracking
Pranay Meshram
 
Entropy-Driven Evolutionary Approaches to the Mastermind Problem
Entropy-Driven Evolutionary Approaches to the Mastermind ProblemEntropy-Driven Evolutionary Approaches to the Mastermind Problem
Entropy-Driven Evolutionary Approaches to the Mastermind Problem
Juan J. Merelo
 
Complex Analysis
Complex AnalysisComplex Analysis
Complex Analysis
Mijanur Rahman
 
Lecture 3.6 bt
Lecture 3.6 btLecture 3.6 bt
Lecture 3.6 bt
btmathematics
 
11.2 graphing linear equations in two variables
11.2 graphing linear equations in two variables11.2 graphing linear equations in two variables
11.2 graphing linear equations in two variables
GlenSchlee
 
Lesson 18
Lesson 18Lesson 18
Lesson 18
NRWEG3
 
Graph plotting using GeoGebra
Graph plotting using GeoGebraGraph plotting using GeoGebra
Graph plotting using GeoGebra
Pratima Nayak ,Kendriya Vidyalaya Sangathan
 
CONSIDER THE INTERVAL [0, ). FOR EACH NUMERICAL VALUE BELOW, IS IT IN THE INT...
CONSIDER THE INTERVAL [0, ). FOR EACH NUMERICAL VALUE BELOW, IS IT IN THE INT...CONSIDER THE INTERVAL [0, ). FOR EACH NUMERICAL VALUE BELOW, IS IT IN THE INT...
CONSIDER THE INTERVAL [0, ). FOR EACH NUMERICAL VALUE BELOW, IS IT IN THE INT...
ViscolKanady
 
Polynomials and Curve Fitting in MATLAB
Polynomials and Curve Fitting in MATLABPolynomials and Curve Fitting in MATLAB
Polynomials and Curve Fitting in MATLAB
Shameer Ahmed Koya
 
Stochastic Processes Homework Help
Stochastic Processes Homework Help Stochastic Processes Homework Help
Stochastic Processes Homework Help
Statistics Assignment Help
 
Sufficient statistics
Sufficient statisticsSufficient statistics
Sufficient statistics
Alessandro Ortis
 
Math 116 pres. 5
Math 116 pres. 5Math 116 pres. 5
Introduction to engineering maths
Introduction to engineering mathsIntroduction to engineering maths
Introduction to engineering maths
Kishore Kumar
 
Alg II 2-7 Transformations
Alg II 2-7 TransformationsAlg II 2-7 Transformations
Alg II 2-7 Transformations
jtentinger
 
First Partial Review
First Partial ReviewFirst Partial Review
First Partial Review
Carlos Vázquez
 
5HBC: How to Graph Implicit Relations Intro Packet!
5HBC: How to Graph Implicit Relations Intro Packet!5HBC: How to Graph Implicit Relations Intro Packet!
5HBC: How to Graph Implicit Relations Intro Packet!
A Jorge Garcia
 
Gr 10 absolute value functions and graphs
Gr 10 absolute value functions and graphsGr 10 absolute value functions and graphs
Gr 10 absolute value functions and graphs
Chadwick International School
 

What's hot (19)

Graphing linear equations
Graphing linear equationsGraphing linear equations
Graphing linear equations
 
Graph Theory
Graph TheoryGraph Theory
Graph Theory
 
Backtracking
BacktrackingBacktracking
Backtracking
 
Entropy-Driven Evolutionary Approaches to the Mastermind Problem
Entropy-Driven Evolutionary Approaches to the Mastermind ProblemEntropy-Driven Evolutionary Approaches to the Mastermind Problem
Entropy-Driven Evolutionary Approaches to the Mastermind Problem
 
Complex Analysis
Complex AnalysisComplex Analysis
Complex Analysis
 
Lecture 3.6 bt
Lecture 3.6 btLecture 3.6 bt
Lecture 3.6 bt
 
11.2 graphing linear equations in two variables
11.2 graphing linear equations in two variables11.2 graphing linear equations in two variables
11.2 graphing linear equations in two variables
 
Lesson 18
Lesson 18Lesson 18
Lesson 18
 
Graph plotting using GeoGebra
Graph plotting using GeoGebraGraph plotting using GeoGebra
Graph plotting using GeoGebra
 
CONSIDER THE INTERVAL [0, ). FOR EACH NUMERICAL VALUE BELOW, IS IT IN THE INT...
CONSIDER THE INTERVAL [0, ). FOR EACH NUMERICAL VALUE BELOW, IS IT IN THE INT...CONSIDER THE INTERVAL [0, ). FOR EACH NUMERICAL VALUE BELOW, IS IT IN THE INT...
CONSIDER THE INTERVAL [0, ). FOR EACH NUMERICAL VALUE BELOW, IS IT IN THE INT...
 
Polynomials and Curve Fitting in MATLAB
Polynomials and Curve Fitting in MATLABPolynomials and Curve Fitting in MATLAB
Polynomials and Curve Fitting in MATLAB
 
Stochastic Processes Homework Help
Stochastic Processes Homework Help Stochastic Processes Homework Help
Stochastic Processes Homework Help
 
Sufficient statistics
Sufficient statisticsSufficient statistics
Sufficient statistics
 
Math 116 pres. 5
Math 116 pres. 5Math 116 pres. 5
Math 116 pres. 5
 
Introduction to engineering maths
Introduction to engineering mathsIntroduction to engineering maths
Introduction to engineering maths
 
Alg II 2-7 Transformations
Alg II 2-7 TransformationsAlg II 2-7 Transformations
Alg II 2-7 Transformations
 
First Partial Review
First Partial ReviewFirst Partial Review
First Partial Review
 
5HBC: How to Graph Implicit Relations Intro Packet!
5HBC: How to Graph Implicit Relations Intro Packet!5HBC: How to Graph Implicit Relations Intro Packet!
5HBC: How to Graph Implicit Relations Intro Packet!
 
Gr 10 absolute value functions and graphs
Gr 10 absolute value functions and graphsGr 10 absolute value functions and graphs
Gr 10 absolute value functions and graphs
 

Similar to data structure and algorithms Unit 5

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
varun arora
 
bcfbedbf-6679-4d5d-b8a5-7d4c9c48dba4.pptx
bcfbedbf-6679-4d5d-b8a5-7d4c9c48dba4.pptxbcfbedbf-6679-4d5d-b8a5-7d4c9c48dba4.pptx
bcfbedbf-6679-4d5d-b8a5-7d4c9c48dba4.pptx
B.T.L.I.T
 
Exhaustive Combinatorial Enumeration
Exhaustive Combinatorial EnumerationExhaustive Combinatorial Enumeration
Exhaustive Combinatorial Enumeration
Mathieu Dutour Sikiric
 
Backtraking pic&def
Backtraking pic&defBacktraking pic&def
Backtraking pic&def
balavigneshwari
 
Stochastic Process Assignment Help
Stochastic Process Assignment HelpStochastic Process Assignment Help
Stochastic Process Assignment Help
Statistics Assignment Help
 
5.5 back track
5.5 back track5.5 back track
5.5 back track
Krish_ver2
 
Analysis and design of algorithms part 4
Analysis and design of algorithms part 4Analysis and design of algorithms part 4
Analysis and design of algorithms part 4
Deepak John
 
Asssignment problem
Asssignment problemAsssignment problem
Asssignment problem
Mamatha Upadhya
 
Stochastic Process Exam Help
Stochastic Process Exam HelpStochastic Process Exam Help
Stochastic Process Exam Help
Statistics Exam Help
 
Daa chapter11
Daa chapter11Daa chapter11
Daa chapter11
B.Kirron Reddi
 
Signals and Systems Homework Help.pptx
Signals and Systems Homework Help.pptxSignals and Systems Homework Help.pptx
Signals and Systems Homework Help.pptx
Matlab Assignment Experts
 
Solution 3.
Solution 3.Solution 3.
Solution 3.
sansaristic
 
BackTracking Algorithm: Technique and Examples
BackTracking Algorithm: Technique and ExamplesBackTracking Algorithm: Technique and Examples
BackTracking Algorithm: Technique and Examples
Fahim Ferdous
 
Back tracking
Back trackingBack tracking
ACM ICPC 2013 NEERC (Northeastern European Regional Contest) Problems Review
ACM ICPC 2013 NEERC (Northeastern European Regional Contest) Problems ReviewACM ICPC 2013 NEERC (Northeastern European Regional Contest) Problems Review
ACM ICPC 2013 NEERC (Northeastern European Regional Contest) Problems Review
Roman Elizarov
 
Perform brute force
Perform brute forcePerform brute force
Perform brute force
SHC
 
Retooling of Color Imaging in ihe Quaternion Algebra
Retooling of Color Imaging in ihe Quaternion AlgebraRetooling of Color Imaging in ihe Quaternion Algebra
Retooling of Color Imaging in ihe Quaternion Algebra
mathsjournal
 
RETOOLING OF COLOR IMAGING IN THE QUATERNION ALGEBRA
RETOOLING OF COLOR IMAGING IN THE QUATERNION ALGEBRARETOOLING OF COLOR IMAGING IN THE QUATERNION ALGEBRA
RETOOLING OF COLOR IMAGING IN THE QUATERNION ALGEBRA
mathsjournal
 
Lesson 1 matrix
Lesson 1 matrixLesson 1 matrix
Lesson 1 matrix
Melvy Dela Torre
 
Greedy Edge Colouring for Lower Bound of an Achromatic Index of Simple Graphs
Greedy Edge Colouring for Lower Bound of an Achromatic Index of Simple GraphsGreedy Edge Colouring for Lower Bound of an Achromatic Index of Simple Graphs
Greedy Edge Colouring for Lower Bound of an Achromatic Index of Simple Graphs
inventionjournals
 

Similar to data structure and algorithms Unit 5 (20)

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
 
bcfbedbf-6679-4d5d-b8a5-7d4c9c48dba4.pptx
bcfbedbf-6679-4d5d-b8a5-7d4c9c48dba4.pptxbcfbedbf-6679-4d5d-b8a5-7d4c9c48dba4.pptx
bcfbedbf-6679-4d5d-b8a5-7d4c9c48dba4.pptx
 
Exhaustive Combinatorial Enumeration
Exhaustive Combinatorial EnumerationExhaustive Combinatorial Enumeration
Exhaustive Combinatorial Enumeration
 
Backtraking pic&def
Backtraking pic&defBacktraking pic&def
Backtraking pic&def
 
Stochastic Process Assignment Help
Stochastic Process Assignment HelpStochastic Process Assignment Help
Stochastic Process Assignment Help
 
5.5 back track
5.5 back track5.5 back track
5.5 back track
 
Analysis and design of algorithms part 4
Analysis and design of algorithms part 4Analysis and design of algorithms part 4
Analysis and design of algorithms part 4
 
Asssignment problem
Asssignment problemAsssignment problem
Asssignment problem
 
Stochastic Process Exam Help
Stochastic Process Exam HelpStochastic Process Exam Help
Stochastic Process Exam Help
 
Daa chapter11
Daa chapter11Daa chapter11
Daa chapter11
 
Signals and Systems Homework Help.pptx
Signals and Systems Homework Help.pptxSignals and Systems Homework Help.pptx
Signals and Systems Homework Help.pptx
 
Solution 3.
Solution 3.Solution 3.
Solution 3.
 
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
 
ACM ICPC 2013 NEERC (Northeastern European Regional Contest) Problems Review
ACM ICPC 2013 NEERC (Northeastern European Regional Contest) Problems ReviewACM ICPC 2013 NEERC (Northeastern European Regional Contest) Problems Review
ACM ICPC 2013 NEERC (Northeastern European Regional Contest) Problems Review
 
Perform brute force
Perform brute forcePerform brute force
Perform brute force
 
Retooling of Color Imaging in ihe Quaternion Algebra
Retooling of Color Imaging in ihe Quaternion AlgebraRetooling of Color Imaging in ihe Quaternion Algebra
Retooling of Color Imaging in ihe Quaternion Algebra
 
RETOOLING OF COLOR IMAGING IN THE QUATERNION ALGEBRA
RETOOLING OF COLOR IMAGING IN THE QUATERNION ALGEBRARETOOLING OF COLOR IMAGING IN THE QUATERNION ALGEBRA
RETOOLING OF COLOR IMAGING IN THE QUATERNION ALGEBRA
 
Lesson 1 matrix
Lesson 1 matrixLesson 1 matrix
Lesson 1 matrix
 
Greedy Edge Colouring for Lower Bound of an Achromatic Index of Simple Graphs
Greedy Edge Colouring for Lower Bound of an Achromatic Index of Simple GraphsGreedy Edge Colouring for Lower Bound of an Achromatic Index of Simple Graphs
Greedy Edge Colouring for Lower Bound of an Achromatic Index of Simple Graphs
 

Recently uploaded

NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptxNEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
iammrhaywood
 
MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
Colégio Santa Teresinha
 
Chapter wise All Notes of First year Basic Civil Engineering.pptx
Chapter wise All Notes of First year Basic Civil Engineering.pptxChapter wise All Notes of First year Basic Civil Engineering.pptx
Chapter wise All Notes of First year Basic Civil Engineering.pptx
Denish Jangid
 
How to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP ModuleHow to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP Module
Celine George
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
Nicholas Montgomery
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
Jean Carlos Nunes Paixão
 
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem studentsRHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
Himanshu Rai
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Akanksha trivedi rama nursing college kanpur.
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Dr. Vinod Kumar Kanvaria
 
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
GeorgeMilliken2
 
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
heathfieldcps1
 
Advanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docxAdvanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docx
adhitya5119
 
Reimagining Your Library Space: How to Increase the Vibes in Your Library No ...
Reimagining Your Library Space: How to Increase the Vibes in Your Library No ...Reimagining Your Library Space: How to Increase the Vibes in Your Library No ...
Reimagining Your Library Space: How to Increase the Vibes in Your Library No ...
Diana Rendina
 
Walmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdfWalmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdf
TechSoup
 
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptxPrésentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
siemaillard
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
National Information Standards Organization (NISO)
 
How to Create a More Engaging and Human Online Learning Experience
How to Create a More Engaging and Human Online Learning Experience How to Create a More Engaging and Human Online Learning Experience
How to Create a More Engaging and Human Online Learning Experience
Wahiba Chair Training & Consulting
 
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
Priyankaranawat4
 
Hindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdfHindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdf
Dr. Mulla Adam Ali
 

Recently uploaded (20)

NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptxNEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
 
MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
 
Chapter wise All Notes of First year Basic Civil Engineering.pptx
Chapter wise All Notes of First year Basic Civil Engineering.pptxChapter wise All Notes of First year Basic Civil Engineering.pptx
Chapter wise All Notes of First year Basic Civil Engineering.pptx
 
How to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP ModuleHow to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP Module
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
 
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem studentsRHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
 
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
 
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
 
Advanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docxAdvanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docx
 
Reimagining Your Library Space: How to Increase the Vibes in Your Library No ...
Reimagining Your Library Space: How to Increase the Vibes in Your Library No ...Reimagining Your Library Space: How to Increase the Vibes in Your Library No ...
Reimagining Your Library Space: How to Increase the Vibes in Your Library No ...
 
Walmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdfWalmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdf
 
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptxPrésentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
 
How to Create a More Engaging and Human Online Learning Experience
How to Create a More Engaging and Human Online Learning Experience How to Create a More Engaging and Human Online Learning Experience
How to Create a More Engaging and Human Online Learning Experience
 
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
 
Hindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdfHindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdf
 

data structure and algorithms Unit 5

  • 1. * Back tracking : The General Method * The 8-Queens Problem *Sum Of Subsets * Graph Coloring
  • 2.  Backtracking represents one of the most general techniques. Many problems which deal with searching for a set solutions or which ask for an optimal solution satisfying some constraints can be solved using backtracking formulation.  In many applications of the backtrack method the desired solution is expressible as an n-tuple (x1,……,xn), Where the xi are chosen from some finite set Si.
  • 3.  For example , Consider the sudoko solving problem, We try filling digits one by one. Whenever we find that current digit cannot lead to a solution, We remove it (backtrack)  And try next digit. This is better than naïve approach ( generating all possible combination of digits and the trying every combination one by one) as it drops a set of permutations whenever it backtracks.
  • 4.  The 8-queens problem via a backtracking solution. In fact we trivially generalize the problem and consider an n*n chess board and try to find all ways to place n nonattacking queens.  Imagine the chessboard squares being numbered as the indices of the two-dimensional array a[1:n,1:n], then we observe that every element on the same diagonal that runs from the upper left to the lower right has the same row-column value.
  • 5.  i – j = k – l (or) i + j = k – l  The first equation implies  j – l = i – k  The second equation implies  j – l = k – i
  • 6.  Sum of subsets problem is to find subset of elements that are selected from a given set whose sum adds up to a given number k. We are considering the set contains non-negative values. It is assumed that the input set is unique (no duplicates are presented ).  One way to find subsets that sum to K is to consider all possible subsets. A Power set contains all those subsets.
  • 7.  Assume given set of 4 elements, say W[1]….W[4]. Tree diagrams can be used to design backtracking algorithms . The following tree diagram depicts approach of generating variable sized tuple.
  • 8.  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 nodes have the same color yet only m colors are used. This is termed the m – colorability decision problem. The d is the degree of the given graph, then it can be colored with d+1 colors. The m-colorability optimization problems asks for the smallest integer m for which the graph G can be colored.
  • 9.  This integer is referred to as the chromatic number of the graph. For example, the graph can be colored with three colors 1,2, and3 . The color of each node is indicated next to it. It can also be seen that three colors are needed to color this graph and hence this graph’s chromatic number 3.