Docsity

U.C. Berkeley CS170 Midterm 1: Algorithms Exam, Exams of Algorithms and Programming

Toggle sidebar
bg1
U.C. Berkeley โ€“ CS170: Algorithms Midterm 1
Lecturers: Umesh Vazirani & Christos Papadimitriou February 26, 2004
Midterm 1
Name:
TA:
Answer all questions. Read them carefully first. Be precise and concise. The number of points indicate the
amount of time (in minutes) each problem is worth spending. Write in the space provided, and use the
back of the page for scratch. Good Luck!
1
2.1
2.2
2.3
2.4
2.5
2.6
2.7
2.8
2
3
total
1
pf3
pf4
pf5

Partial preview of the text

Download U.C. Berkeley CS170 Midterm 1: Algorithms Exam and more Exams Algorithms and Programming in PDF only on Docsity!

U.C. Berkeley โ€“ CS170: Algorithms Midterm 1 Lecturers: Umesh Vazirani & Christos Papadimitriou February 26, 2004

Midterm 1

Name:

TA:

Answer all questions. Read them carefully first. Be precise and concise. The number of points indicate the amount of time (in minutes) each problem is worth spending. Write in the space provided, and use the back of the page for scratch. Good Luck!

1

2 3 total

Problem 1

(15 points) Do a depth-first search of the graph below. Follow our convention of processing nodes in lexicographic order. Show the pre and post order numbers. How many strongly connected components are there (no need to show how to find them). What is the graph after you shrink them?

  1. (5 points) What is (mod 47)?
  2. (5 points) How many lines, as a function of n (a power of 2) in form, will this program print? Write a recurrence and solve it.

boring(n) if n > 1 do: {print(โ€œare we done yet?โ€); boring(n/2); boring(n/2)}

  1. (5 points) We denote the discrete Fourier transform of (1, 0, 1, -1) by (A 0 , A 1 , A 2 , A 3 ). What is  in this case? And what is A 3?
  1. (5 points) The FFT and its inverse are based on certain properties of (equations satisfied by)  What are they?
  2. (10 points) Is each of the following statements true or false? Explain briefly. (1) If the depth-first search of a directed graph has a cross edge, the graph is not strongly connected. (2) If a graph is not strongly connected, then its depth-first search must have a cross edge.