Theoretical Algorithms - Efficient Algorithms and Intractable Problems - Exams, Exams of Algorithms and Programming

Main points of this exam paper are: Theoretical Algorithms, Number Theoretical, Asymptotic Upper, Upper Bound, Encoding, Algorithm Design, Sorted Arrays, Fft Matrix, Depth Rst Search, Starting Point

Typology: Exams

2012/2013

Uploaded on 04/02/2013

sushmi_98
sushmi_98 🇮🇳

4.5

(4)

51 documents

1 / 6

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
UC Berkeley—CS 170 Midterm 1
Lecturer: Satish Rao March 10
Midterm 1 for CS 170
Print your name: ,
(last) (first)
Sign your name:
Write your section number (e.g., 101):
Write your SID:
One page of notes is permitted. No electronic devices, e.g. cell phones and calculators, are
permitted. Do all your work on the pages of this examination. If you need more space, you
may use the reverse side of the page, but try to use the reverse of the same page where the
problem is stated.
You have 80 minutes. The questions are of varying difficulty, so avoid spending too long on
any one question.
In all algorithm design problems, you may use high-level pseudocode.
DO NOT TURN THE PAGE UNTIL YOU ARE TOLD TO DO SO.
Problem Score/Points
Name/Section/etc. /5
1 /20
2 /20
3 /20
4 /20
5 /15
Total /100
pf3
pf4
pf5

Partial preview of the text

Download Theoretical Algorithms - Efficient Algorithms and Intractable Problems - Exams and more Exams Algorithms and Programming in PDF only on Docsity!

UC Berkeley—CS 170 Midterm 1 Lecturer: Satish Rao March 10

Midterm 1 for CS 170

Print your name:

(last) (first)

Sign your name:

Write your section number (e.g., 101):

Write your SID:

One page of notes is permitted. No electronic devices, e.g. cell phones and calculators, are permitted. Do all your work on the pages of this examination. If you need more space, you may use the reverse side of the page, but try to use the reverse of the same page where the problem is stated.

You have 80 minutes. The questions are of varying difficulty, so avoid spending too long on any one question.

In all algorithm design problems, you may use high-level pseudocode.

DO NOT TURN THE PAGE UNTIL YOU ARE TOLD TO DO SO.

Problem Score/Points Name/Section/etc. / 1 / 2 / 3 / 4 / 5 / Total /

1. True/False. No need to justify your answer. [2 points per problem]

Answer true or false for each. Scoring is 2 points for correct answer and -2 points for incorrect.

  1. 2n^ = Ω(n!).
  2. 3log^

√n = Θ(

n).

  1. If f (n) = O(g(n)), then g(n) = Ω(f (n)).

∑n j=1 j^ =^ O(n^ log^ n).

  1. If T (n) = 4T (n/2) + O(n) then T (n) = O(n^3 ).
  2. If T (n) = 4T (n/2) + O(n) then T (n) = O(n^2 log n).
  3. If an−^1 ≡ 1 mod n for all positive integers a < n, then n is prime.
  4. The probability that an n-bit integer is prime is roughly 2−n.
  5. Any DAG with a unique source and sink has a unique topological ordering.
  6. Breadth first search and depth first search produces the same tree on connected undi- rected graphs if and only if the graph is a tree.

3. Algorithm Design and FFT.

  1. Given k sorted arrays of length l, sketch an algorithm for finding the median element of all the kl elements. Justify the correctness and give and justify running time bounds. (We are looking for a solution that takes o(kl) time.)
  2. What is the FFT matrix for a four point FFT? What is the FFT of (0,0,0,1)? of (1,0,0,0)?

4. Depth first Search. 20 points.

Given only the ability to run DFS on a graph from any starting point u and obtaining the resulting pre and post order numbers. (You never get to see an edge.) (Remark: these are pretty easy so don’t worry if it seems so.)

  1. Show how to find a pair of vertices that is in a cycle in a directed graph if there is one. (You can call DFS as many times as you like on different starting point.)
  2. If for some DFS [pre(u), post(u)] is disjoint from [pre[v], post(v)], what is the relative order of the intervals if u is reachable from v?
  3. For a connected undirected graph where the starting point is on a cycle, what is the pre and post numbers of the starting point in terms of the number of nodes in the graph. What if the graph is not connected?