quiz2 - Introduction to Algorithms Massachusetts Institute...

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

View Full Document Right Arrow Icon
Introduction to Algorithms November 17, 2011 Massachusetts Institute of Technology 6.006 Fall 2011 Professors Erik Demaine and Srini Devadas Quiz 2 Solutions Quiz 2 Solutions Problem 1. [1 points] Write your name on top of each page. Problem 2. True/False [28 points] (14 parts) Circle (T)rue or (F)alse. You don’t need to justify your choice. (a) T F [2 points] Computing b a c for an n -bit positive integer a can be done in O (lg n ) iterations of Newton’s method. Solution: True. This is the bound obtained by Newton’s Method’s quadratic convergence. (b) T F [2 points] Suppose we want to solve a polynomial equation f ( x ) = 0 . While our choice of initial approximation x 0 will affect how quickly Newton’s method converges, it will always converge eventually. Solution: False. Take e.g. f ( x ) = x 3 - 2 x +2 and x 0 = 0 . Then x 2 i +1 = 1 and x 2 i = 0 for all i (that is, the approximations alternate between 0 and 1 without ever converging). (c) T F [2 points] Karatsuba’s integer multiplication algorithm always runs faster than the grade-school integer multiplication algorithm. Solution: False. Problem Set 5 has shown that the O ( N 2 ) algorithm runs faster for small numbers. (d) T F [2 points] If we convert an n -digit base-256 number into base 2, the resulting number of digits is Θ( n 2 ) . Solution: False. log 256 n = log 2 n = log 2 n log 256 8 . By converting a base-256 number to base 2, the number of digits is 2 multiplied by 8. For all b 1 ,b 2 = 1 , converting a base- b 1 number to base- b 2 results in a linear increase or decrease in the number of digits. (e) T F [2 points] In a weighted undirected graph G = ( V,E,w ) , breadth-first search from a vertex s finds single-source shortest paths from s (via parent pointers) in O ( V + E ) time. Solution: False. Only in unweighted graphs. (f) T F [2 points] In a weighted undirected tree G = ( ) , breadth-first search from a vertex s finds single-source shortest paths from s (via parent pointers) in O ( V + E ) time. 6
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
6.006 Quiz 2 Solutions Name 2 Solution: True. In a tree, there is only one path between two vertices, and breadth-first search finds it. (g) T F [2 points] In a weighted undirected tree G = ( V,E,w ) , depth -first search from a vertex s finds single-source shortest paths from s (via parent pointers) in O ( V + E ) time. Solution: True. In a tree, there is only one path between two vertices, and depth-first search finds it. (h) T F [2 points] If a graph represents tasks and their interdependencies (i.e., an edge ( u,v ) indicates that u must happen before v happens), then the breadth-first search order of vertices is a valid order in which to tackle the tasks. Solution: No, you’d prefer depth-first search, which can easily be used to pro- duce a topological sort of the graph, which would correspond to a valid task order. BFS can produce incorrect results. (i) T F [2 points] Dijkstra’s shortest-path algorithm may relax an edge more than once in a graph with a cycle.
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Page1 / 14

quiz2 - Introduction to Algorithms Massachusetts Institute...

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

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