CS 212

CS 212 - Backtracking...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
Backtracking I. Introduction II. Formulation of the Problem of Generating Combinatorial Objects III. The General Backtracking Algorithm IV. Implementations for the Eight Applications I. Introduction Backtracking is a systematic method for generating all (or subsets of) combinortial objects. Examples of combinatorial objects include Binary strings of n bits 1. Subsets of a given set E of n elements 2. Directed graphs of n nodes 3. Undirected graphs of n nodes 4. Permutations of a given size n 5. Hamiltonian cycles of a given graph 6. K-cliques of a given graph 7. K-colorings of a given graph 8. Back to Top II. Formulation of the Problem of Generating Combinatorial Objects In most of the generation problems, we have Each object is represented by an array X[1:/] 1. Backtracking http://www.seas.gwu.edu/~ayoussef/cs212/backtracking.html 1 of 8 9/3/2010 4:52 AM
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
The elements of the array are taken from a domain S={a 1 ,a 2 ,...,a m }. Often, S is a finite set of successive integers. 2. The values of array X must satisfy some constraints C so that X represents a legitimate object of the type in question. 3. We will show the specifics in each of the following instances of combinatorial object generation Problem 1: Generation of all n-bit binary strings Every n-bit binary string is represented by an array X[1:n] X[i] takes its values from {0,1} The constrainst C are empty because the values of the individual bits are indepedent Problem 2: Generation of all subsets of the set {1,2,. ..,n} Every subset is represented by the bitmap (i.e., Boolean array) X[1:n]; X[i] takes its values from {0,1}. X[i]=1 if i is in the subset being represented; X[i]=0 if i is not in the subset being represented. The constrainst C are empty because whether i is an element of the subset has no bearing on whether or not j is an element of the subset. Problem 3: Generation of all directed graphs of n nodes Every digraph of n nodes is representable by a 2D array A[1:n,1:n], which is the well-known adjacency matrix. The values of the entries in the array are binary and also are independent of one another. The 2D array can be represented by a a 1D binary array X[1:/] where /=n 2 The value of each X[i] is in {0,1} The constraints C are empty because the values of entries of X (which are the entries of A) are independent Mapping from A to X: Stack the rows of A one after another. Thus, X[(i-1)n + j] = A[i,j] Problem 4: Generation of all undirected graphs of n nodes Every graph of n nodes is also representable by the 2D adjacency matrix A[1:n,1:n]. The values of the entries in the array are binary but are not independent of one another: A[i,j] = A[j,i] for all i and j Which is the symmetry contraint (or property) The 2D array can be represented by a a 1D binary array X[1:/] where /=n 2 , like in the Backtracking http://www.seas.gwu.edu/~ayoussef/cs212/backtracking.html 2 of 8 9/3/2010 4:52 AM
Background image of page 2
case of directed graphs, but this time with the symmetry constraint. A preferable alternative is to only represent the upper triangle only, and thus eliminate the
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Page1 / 8

CS 212 - Backtracking...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online