Partial preview of the text
Download Postvisit Numbers - Efficient Algorithms and Intractable Problems - Solved Exams and more Exams Algorithms and Programming in PDF only on Docsity!
C5170 Solutions to the Second Midterm . (2 points each question) True or false? Circle the correct answer. No explanation required. No points will be subtracted lor incorrect answers, so guess all you want. F In an undirected graph, the shortest path between two nodes always lics on some minimum spanning tree. false, think of a graph with three nodes, a,6,¢ with edge weights: (a,6) = 4, (d,¢) = 5, (ea) = 6. The MST will consist of edges (a, 6) and (6,c), but the shortest path. from a to ¢ is not on the MST. FP If all edges of a graph hawe different weights the minimum spanning tree is unique. ‘True, you proved this on your haw. F If all edges of a graph have different weights the second-best minimum spanning tree is unique. Fa consider a graph consisling of lwo triangles sharing onc ve The first triangle has edge weights 1,2,3 and the second, 4,5,6. Then we obtain second-best MS's by replacing 2 with 3 OR by replacing 3 » 6. If all edges of the graph have different weights then the highest weight spanning tree is unique. Truc, just multiply all the edge weights by -1 and you convert this to an MST problem. LF Prim’s algorithm for computing minimum spanning trees runs in O(|V?]) steps True, Prim has the same running time as Dijkstra which, implemented with a linked list, runs in O(|V2|) steps. In a depth first search on a directed acyclic graph, the vertex with the highest postorder number is necessarily a source. True. F In Iluffman coding, the item with the second-lowest probability is always at the leaf that is furthest from the root. True. PF In Huffman coding, the item with the highest. probability is always at the leaf that. is closest to the root. Truc. Fo In Huffman coding, the item with the highest probability is always at a leaf that is the child of the root, False. he children of the root aren’t necessarily leaves. TI Ifaset of Horn clauses contains uo clause with a single literal, then it is satisfiable. True. F A set of Horn clauses can be tested for satisfiability in linear time. Truc. F In a depth-first search of a directed graph, it is possible to have an edge between two vertices u and v with previsit and postvisit uumbers: (10,40) for u and (30, 50) for v. false.