Docsity

CS170 Midterm 1 Exam, Fall 2006, Papadimitriou/Vazirani, Exams of Algorithms and Programming

Partial preview of the text

Download CS170 Midterm 1 Exam, Fall 2006, Papadimitriou/Vazirani and more Exams Algorithms and Programming in PDF only on Docsity!

CS170, Fall 2006, Midterm 1, Papadimitriou/Vazirani

NAME: _____________________________

TA: ________________________________

CS170 Midterm 1 October 4, 2006

  • Be clear and concise.
  • Total number of points is 50. So, you may use the number of points assigned to each problem as a rough estimate for the number of minutes you might allocate to the problem.
  • Use the back pages as scratch paper.

1

total

  1. ((20 points) Short questions)
    • How many numbers x are there between 1 and 90 such that x mod 5 = 1 and x mod 3 = 2?
    • What is 3^800 mod 15?
    • In RSA, p = 7, q = 13, e = 5. Why is e = 5 an appropriate choice?
    • What is the solution of T(n) = T(n/2) + 1, T( 1 ) = 0?
    • True or False? Explain very briefly: If ω is the nth^ root of 1, then for any k ≤ n
    • You wish to multiply the polynomials x^2 + 2 and x^3 + x – 1 using the FFT. At which points will you evaluate these polynomials? Write any complex numbers in your answer as a + ib.
  1. (20 points)
    • Perform depth-first search on this directed graph. Give the Previsit and Postvisit numbers of the nodes. Process nodes in alphabetical order (node A is visited first, and edge AB is visited before AD).
    • A vista vertex of a directed graph is a vertex from which all other vertices are reachable. Does the graph above contain a vista vertex?
    • True or False? (Explain briefly): If a graph has a vista vertex, it will be the last vertex from which explore is called in the main loop of depth-first search.
    • Give a linear-time algorithm for telling if a graph has a vista vertex. Briefly justify its correctness. Why is it linear?