0% found this document useful (0 votes)
17 views

Programming Challenges 18-18

The document discusses graphs and networks including planar graphs, minimum spanning trees, shortest paths, network flows, and bipartite matching. It then covers dynamic programming including edit distance, program design examples, and problems involving grids, dynamic programming, graphs and networks.

Uploaded by

Sandeep Singh
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views

Programming Challenges 18-18

The document discusses graphs and networks including planar graphs, minimum spanning trees, shortest paths, network flows, and bipartite matching. It then covers dynamic programming including edit distance, program design examples, and problems involving grids, dynamic programming, graphs and networks.

Uploaded by

Sandeep Singh
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Contents xvii

10.1.4 Planar Graphs . . . . . . . . . . . . . . . . . . . . . . . . . . . 220


10.2 Minimum Spanning Trees . . . . . . . . . . . . . . . . . . . . . . . . 220
10.3 Shortest Paths . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223
10.3.1 Dijkstra’s Algorithm . . . . . . . . . . . . . . . . . . . . . . . 223
10.3.2 All-Pairs Shortest Path . . . . . . . . . . . . . . . . . . . . . . 225
10.4 Network Flows and Bipartite Matching . . . . . . . . . . . . . . . . . 227
10.5 Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 231
10.5.1 Freckles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 231
10.5.2 The Necklace . . . . . . . . . . . . . . . . . . . . . . . . . . . 232
10.5.3 Fire Station . . . . . . . . . . . . . . . . . . . . . . . . . . . . 234
10.5.4 Railroads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235
10.5.5 War . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 237
10.5.6 Tourist Guide . . . . . . . . . . . . . . . . . . . . . . . . . . . 239
10.5.7 The Grand Dinner . . . . . . . . . . . . . . . . . . . . . . . . 241
10.5.8 The Problem With the Problem Setter . . . . . . . . . . . . . 242
10.6 Hints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 244

11 Dynamic Programming 245


11.1 Don’t Be Greedy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245
11.2 Edit Distance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 246
11.3 Reconstructing the Path . . . . . . . . . . . . . . . . . . . . . . . . . 250
11.4 Varieties of Edit Distance . . . . . . . . . . . . . . . . . . . . . . . . 251
11.5 Program Design Example: Elevator Optimization . . . . . . . . . . . 253
11.6 Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257
11.6.1 Is Bigger Smarter? . . . . . . . . . . . . . . . . . . . . . . . . 257
11.6.2 Distinct Subsequences . . . . . . . . . . . . . . . . . . . . . . 258
11.6.3 Weights and Measures . . . . . . . . . . . . . . . . . . . . . . 259
11.6.4 Unidirectional TSP . . . . . . . . . . . . . . . . . . . . . . . . 260
11.6.5 Cutting Sticks . . . . . . . . . . . . . . . . . . . . . . . . . . . 262
11.6.6 Ferry Loading . . . . . . . . . . . . . . . . . . . . . . . . . . . 263
11.6.7 Chopsticks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 265
11.6.8 Adventures in Moving: Part IV . . . . . . . . . . . . . . . . . 266
11.7 Hints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 267
11.8 Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 267

12 Grids 268
12.1 Rectilinear Grids . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 268
12.1.1 Traversal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269
12.1.2 Dual Graphs and Representations . . . . . . . . . . . . . . . . 270
12.2 Triangular and Hexagonal Grids . . . . . . . . . . . . . . . . . . . . . 271
12.2.1 Triangular Lattices . . . . . . . . . . . . . . . . . . . . . . . . 271
12.2.2 Hexagonal Lattices . . . . . . . . . . . . . . . . . . . . . . . . 272
12.3 Program Design Example: Plate Weight . . . . . . . . . . . . . . . . 275
12.4 Circle Packings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 277
12.5 Longitude and Latitude . . . . . . . . . . . . . . . . . . . . . . . . . . 278

You might also like