The.Algorithm.Design.Manual.Springer-Verlag.1998
The.Algorithm.Design.Manual.Springer-Verlag.1998 The.Algorithm.Design.Manual.Springer-Verlag.1998
War Story: Dialing for Documents Next: Exercises Up: Graph Algorithms Previous: War Story: Nothing but Algorithms Mon Jun 2 23:33:50 EDT 1997 file:///E|/BOOK/BOOK2/NODE80.HTM (6 of 6) [19/1/2003 1:29:21]
Exercises Next: Implementation Challenges Up: Graph Algorithms Previous: War Story: Dialing for Exercises 1. Present correct and efficient algorithms to convert between the following graph data structures, for an undirected graph G with n vertices and m edges. You must give the time complexity of each algorithm. 1. Convert from an adjacency matrix to adjacency lists. 2. Convert from an adjacency list to an incidence matrix. An incidence matrix M has a row for each vertex and a column for each edge, such that M[i,j]=1 if vertex i is part of edge j, otherwise M[i,j] = 0. 3. Convert from an incidence matrix to adjacency lists. 2. Is the path between a pair of vertices in a minimum spanning tree necessarily a shortest path between the two vertices in the full graph? Give a proof or a counterexample. 3. Assume that all edges in the graph have distinct edge weights (i.e. no pair of edges have the same weight). Is the path between a pair of vertices in a minimum spanning tree necessarily a shortest path between the two vertices in the full graph? Give a proof or a counterexample. 4. Suppose G is a connected undirected graph. An edge e whose removal disconnects the graph is called a bridge. Must every bridge e be an edge in a depth-first search tree of G, or can e be a back edge? Give a proof or a counterexample. 5. (*) In breadth-first and depth-first search, an undiscovered node is marked discovered when it is first encountered, and marked completely-explored when it has been completely searched. At any given moment, several nodes might be simultaneously in the discovered state. (a) Describe a graph on n vertices and a particular starting vertex v such that during a breadth-first search starting from v, nodes are simultaneously in the discovered state. (b) Describe a graph on n vertices and a particular starting vertex v such that during a depth-first search starting from v, nodes are simultaneously in the discovered state. (c) Describe a graph on n vertices and a particular starting vertex v such that at some point during a depth-first search starting from v, nodes remain undiscovered, while nodes have been completely-explored. (Note, there may also be discovered nodes.) 6. Given the pre-order and in-order traversals of a binary tree, is it possible to reconstruct the tree? If file:///E|/BOOK/BOOK2/NODE81.HTM (1 of 3) [19/1/2003 1:29:23]
- Page 213 and 214: Binary Search Next: Square and Othe
- Page 215 and 216: Exercises Next: Implementation Chal
- Page 217 and 218: Exercises whose denominations are ,
- Page 219 and 220: The Friendship Graph Next: Data Str
- Page 221 and 222: The Friendship Graph friendship gra
- Page 223 and 224: Data Structures for Graphs linked t
- Page 225 and 226: War Story: Getting the Graph ``Well
- Page 227 and 228: Traversing a Graph Next: Breadth-Fi
- Page 229 and 230: Breadth-First Search Next: Depth-Fi
- Page 231 and 232: Depth-First Search Next: Applicatio
- Page 233 and 234: Depth-First Search Next: Applicatio
- Page 235 and 236: Connected Components Next: Tree and
- Page 237 and 238: Two-Coloring Graphs Next: Topologic
- Page 239 and 240: Topological Sorting Next: Articulat
- Page 241 and 242: Modeling Graph Problems Next: Minim
- Page 243 and 244: Modeling Graph Problems good line s
- Page 245 and 246: Minimum Spanning Trees ● Prim's A
- Page 247 and 248: Prim's Algorithm inserted edge (x,y
- Page 249 and 250: Kruskal's Algorithm a tree of weigh
- Page 251 and 252: Dijkstra's Algorithm Next: All-Pair
- Page 253 and 254: All-Pairs Shortest Path Next: War S
- Page 255 and 256: War Story: Nothing but Nets Next: W
- Page 257 and 258: War Story: Nothing but Nets ``You a
- Page 259 and 260: War Story: Dialing for Documents Ne
- Page 261 and 262: War Story: Dialing for Documents If
- Page 263: War Story: Dialing for Documents CO
- Page 267 and 268: Exercises Prove the statement or gi
- Page 269 and 270: Backtracking report it. kth element
- Page 271 and 272: Constructing All Subsets Next: Cons
- Page 273 and 274: Constructing All Paths in a Graph N
- Page 275 and 276: Search Pruning Next: Bandwidth Mini
- Page 277 and 278: Bandwidth Minimization immediately
- Page 279 and 280: War Story: Covering Chessboards Nex
- Page 281 and 282: War Story: Covering Chessboards att
- Page 283 and 284: Heuristic Methods Mon Jun 2 23:33:5
- Page 285 and 286: Simulated Annealing Return S then u
- Page 287 and 288: Traveling Salesman Problem Next: Ma
- Page 289 and 290: Independent Set Next: Circuit Board
- Page 291 and 292: Neural Networks Next: Genetic Algor
- Page 293 and 294: Genetic Algorithms Next: War Story:
- Page 295 and 296: War Story: Annealing Arrays Next: P
- Page 297 and 298: War Story: Annealing Arrays optimal
- Page 299 and 300: Parallel Algorithms Next: War Story
- Page 301 and 302: War Story: Going Nowhere Fast Next:
- Page 303 and 304: Exercises Next: Implementation Chal
- Page 305 and 306: Problems and Reductions Next: Simpl
- Page 307 and 308: Simple Reductions Next: Hamiltonian
- Page 309 and 310: Hamiltonian Cycles Next: Independen
- Page 311 and 312: Independent Set and Vertex Cover pr
- Page 313 and 314: Clique and Independent Set These la
Exercises<br />
Next: Implementation Challenges Up: Graph <strong>Algorithm</strong>s Previous: War Story: Dialing for<br />
Exercises<br />
1. Present correct and efficient algorithms to convert between the following graph data structures,<br />
for an undirected graph G with n vertices and m edges. You must give the time complexity of<br />
each algorithm.<br />
1. Convert from an adjacency matrix to adjacency lists.<br />
2. Convert from an adjacency list to an incidence matrix. An incidence matrix M has a row<br />
for each vertex and a column for each edge, such that M[i,j]=1 if vertex i is part of edge j,<br />
otherwise M[i,j] = 0.<br />
3. Convert from an incidence matrix to adjacency lists.<br />
2. Is the path between a pair of vertices in a minimum spanning tree necessarily a shortest path<br />
between the two vertices in the full graph? Give a proof or a counterexample.<br />
3. Assume that all edges in the graph have distinct edge weights (i.e. no pair of edges have the same<br />
weight). Is the path between a pair of vertices in a minimum spanning tree necessarily a shortest<br />
path between the two vertices in the full graph? Give a proof or a counterexample.<br />
4. Suppose G is a connected undirected graph. An edge e whose removal disconnects the graph is<br />
called a bridge. Must every bridge e be an edge in a depth-first search tree of G, or can e be a<br />
back edge? Give a proof or a counterexample.<br />
5. (*) In breadth-first and depth-first search, an undiscovered node is marked discovered when it is<br />
first encountered, and marked completely-explored when it has been completely searched. At any<br />
given moment, several nodes might be simultaneously in the discovered state.<br />
(a) Describe a graph on n vertices and a particular starting vertex v such that during a breadth-first<br />
search starting from v, nodes are simultaneously in the discovered state.<br />
(b) Describe a graph on n vertices and a particular starting vertex v such that during a depth-first<br />
search starting from v, nodes are simultaneously in the discovered state.<br />
(c) Describe a graph on n vertices and a particular starting vertex v such that at some point during<br />
a depth-first search starting from v, nodes remain undiscovered, while nodes have been<br />
completely-explored. (Note, there may also be discovered nodes.)<br />
6. Given the pre-order and in-order traversals of a binary tree, is it possible to reconstruct the tree? If<br />
file:///E|/BOOK/BOOK2/NODE81.HTM (1 of 3) [19/1/2003 1:29:23]