Professional Documents
Culture Documents
Backtracking
Reading Assignment
M. Alsuwaiyel, Introduction to Algorithms:
Design Techniques and Analysis, World
Scientific Publishing Co., Inc. 1999.
Chapter 13, Sections 1, 2 and 4.
Backtracking
Backtracking
Backtracking
Backtracking
A systematic technique of searching
To reduce the search space
Can be considered as an organized exhaustive
search
Backtracking
3-Coloring Problem
Optimization Problem
Input: G = (V, E), an undirected graph with n vertices and
m edges.
Output: A 3-coloring of G, if possible.
Backtracking
Example
Backtracking
Backtracking
Example
In the example
Nodes are generated in a depth-first search
manner
No need to store the whole search tree, just the
current active path
What is the time complexity of the algorithm in
the worst case
Algorithm 3-ColorRec
Backtracking
10
Algorithm 3-ColorIter
Backtracking
11
Backtracking
12
Backtracking
Backtracking
13
14
Backtracking
15
BacktrackRec
Backtracking
16
BacktrackIter
Backtracking