0% found this document useful (0 votes)
100 views2 pages

Fundamental Algorithms Final Exam

There will be a final exam for the Fundamental Algorithms course that covers topics like rod cutting algorithms, sorting algorithms, graph algorithms, recursion, modular exponentiation, Huffman coding, the Chinese Remainder Theorem, complexity classes like NP, and graph search algorithms. The exam will consist of multiple choice and free response questions testing understanding of algorithms and their analysis.

Uploaded by

Aashish D
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
100 views2 pages

Fundamental Algorithms Final Exam

There will be a final exam for the Fundamental Algorithms course that covers topics like rod cutting algorithms, sorting algorithms, graph algorithms, recursion, modular exponentiation, Huffman coding, the Chinese Remainder Theorem, complexity classes like NP, and graph search algorithms. The exam will consist of multiple choice and free response questions testing understanding of algorithms and their analysis.

Uploaded by

Aashish D
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Fundamental Algorithms

FINAL EXAM
There will be little rubs and disappointments everywhere, and
we are all apt to expect too much; but then, if one scheme of
happiness fails, human nature turns to another; if the first cal-
culation is wrong, we make a second better.
from Mansfield Park by Jane Austen

1. (20) Describe the algorithm TOPDOLLAR(P RICE,N ). The input is an


array of nonnegative real numbers P RICE[1 N ] where P RICE[I]
represents the price for a rod of length I. Your output should be
V ALU E, which should be the optimal total price among all cuttings
of the rod. You may, and should, use an auxilliary array. You may
write in pseudocode or actual code but in either case you must give
clear comments describing what you are doing and why it works. An-
alyze (just the answer will not suffice!), in -land, the time for your
algorithm.

2. (5) For n large which is faster: (lg3 n) or ( n) algorithm?

3. (15) Given A[1 N ] with 0 A[I] < N N for all I.

(a) How long will COUNTING-SORT take?


(b) How long will RADIX-SORT take using base N ?
(c) Give an algorithm (no proof required!) that does better than
both of the above, and does so in worst case.

4. (5) In a max Heap what is the property of the value at the root? (That
is, how does it compare to the values of the other nodes.)

5. (20) Let G be a connected graph on vertex set V . Let a nonnegative


weight w(e) be assigned to every edge e. Let S V with S 6= and
S 6= V .

(a) Prove (yes, prove!) that the Minimal Spanning Tree necessarily
contains that edge e = {x, y} with x S and y 6 S which has
minimal weight. A good picture wont hurt. Assume no two
edges have the same weight. (Warning: Saying that an algorithm
tells you to pick this edge e is not a proof!)
(b) In what algorithm is the above result used.
6. (10) Consider the recursion T (2n) = 3T (n) + n + 1 with initial value
T (1) = 5.

(a) What is T (4)?


(b) What it T (n) in -land.

7. (20) If multiplication mod p takes 1 second then show, using Island-


Hopping, how to calculate x1023 quickly. How many seconds did it
take? (Hint: What is special about 1023?)

8. (20) Find the Huffman code on letters a, b, c, d, e, f with frequencies


.13, .16, .09, .45, .05, .12 respectively. Give pictures and words clearly
indicating the intermediate steps in finding the code.

9. (5) State the Chinese Remainder Theorem.

10. (15) We call a positive integer n SQUAREFREE if there is no integer d > 1


with d2 dividing n. We call n NOTSQUAREFREE if n is not SQUAREFREE.

(a) Argue NOTSQUAREFREE is in NP.


(b) (This is harder!) Argue SQUAREFREE is in NP.

11. (5) What was the breakthrough of Agrawal, Kayal and Saxena?

12. (20) In Depth-First Search each vertex v gets a discovery time d[v] and
a finishing time f [v]. Let G be a graph and v, w two distinct vertices
for which w Adj[v].

(a) Assume d[v] < d[w]. Argue that f [w] < f [v].
(b) Now further assume that G is a DAG (a Directed Acyclic Graph.)
Assume d[w] < d[v]. Argue that f [w] < f [v].

13. (5) What is the difference, if any, between a (lg n) algorithm and a
(log10 n) algorithm? (Short reason please.)

In the end the great truth will have been learned, that the quest
is greater than what is sought, the effort finer than the prize, or
rather that the effort is the prize, the victory cheap and hollow
were it not for the rigor of the game.
Justice Benjamin Cardozo

You might also like