0% found this document useful (0 votes)
26 views1 page

Programming Challenges 17-17

The document outlines chapters 8 through 10 of a book on algorithms and data structures. Chapter 8 discusses backtracking algorithms for problems like constructing subsets and permutations. It also provides examples like the eight queens problem and pruning search trees. Chapter 9 covers graph traversal algorithms like breadth-first search and depth-first search. It discusses representing graphs with data structures and algorithms for finding paths, cycles, and connected components in graphs. Chapter 10 introduces graph theory concepts like degree properties, connectivity, and cycles, which are important foundations for graph algorithms.

Uploaded by

Sandeep Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views1 page

Programming Challenges 17-17

The document outlines chapters 8 through 10 of a book on algorithms and data structures. Chapter 8 discusses backtracking algorithms for problems like constructing subsets and permutations. It also provides examples like the eight queens problem and pruning search trees. Chapter 9 covers graph traversal algorithms like breadth-first search and depth-first search. It discusses representing graphs with data structures and algorithms for finding paths, cycles, and connected components in graphs. Chapter 10 introduces graph theory concepts like degree properties, connectivity, and cycles, which are important foundations for graph algorithms.

Uploaded by

Sandeep Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

xvi Contents

8 Backtracking 167
8.1 Backtracking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167
8.2 Constructing All Subsets . . . . . . . . . . . . . . . . . . . . . . . . . 169
8.3 Constructing All Permutations . . . . . . . . . . . . . . . . . . . . . . 170
8.4 Program Design Example: The Eight-Queens Problem . . . . . . . . 172
8.5 Pruning Search . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173
8.6 Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176
8.6.1 Little Bishops . . . . . . . . . . . . . . . . . . . . . . . . . . . 176
8.6.2 15-Puzzle Problem . . . . . . . . . . . . . . . . . . . . . . . . 177
8.6.3 Queue . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179
8.6.4 Servicing Stations . . . . . . . . . . . . . . . . . . . . . . . . . 180
8.6.5 Tug of War . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181
8.6.6 Garden of Eden . . . . . . . . . . . . . . . . . . . . . . . . . . 182
8.6.7 Color Hash . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184
8.6.8 Bigger Square Please... . . . . . . . . . . . . . . . . . . . . . . 186
8.7 Hints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188
8.8 Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188

9 Graph Traversal 189


9.1 Flavors of Graphs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189
9.2 Data Structures for Graphs . . . . . . . . . . . . . . . . . . . . . . . 191
9.3 Graph Traversal: Breadth-First . . . . . . . . . . . . . . . . . . . . . 194
9.3.1 Breadth-First Search . . . . . . . . . . . . . . . . . . . . . . . 194
9.3.2 Exploiting Traversal . . . . . . . . . . . . . . . . . . . . . . . 195
9.3.3 Finding Paths . . . . . . . . . . . . . . . . . . . . . . . . . . . 196
9.4 Graph Traversal: Depth-First . . . . . . . . . . . . . . . . . . . . . . 198
9.4.1 Finding Cycles . . . . . . . . . . . . . . . . . . . . . . . . . . 198
9.4.2 Connected Components . . . . . . . . . . . . . . . . . . . . . 199
9.5 Topological Sorting . . . . . . . . . . . . . . . . . . . . . . . . . . . . 200
9.6 Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203
9.6.1 Bicoloring . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203
9.6.2 Playing With Wheels . . . . . . . . . . . . . . . . . . . . . . . 204
9.6.3 The Tourist Guide . . . . . . . . . . . . . . . . . . . . . . . . 206
9.6.4 Slash Maze . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208
9.6.5 Edit Step Ladders . . . . . . . . . . . . . . . . . . . . . . . . . 210
9.6.6 Tower of Cubes . . . . . . . . . . . . . . . . . . . . . . . . . . 211
9.6.7 From Dusk Till Dawn . . . . . . . . . . . . . . . . . . . . . . . 213
9.6.8 Hanoi Tower Troubles Again! . . . . . . . . . . . . . . . . . . 215
9.7 Hints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 216

10 Graph Algorithms 217


10.1 Graph Theory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 217
10.1.1 Degree Properties . . . . . . . . . . . . . . . . . . . . . . . . . 217
10.1.2 Connectivity . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218
10.1.3 Cycles in Graphs . . . . . . . . . . . . . . . . . . . . . . . . . 219

You might also like