Algo Quiz 1
Algo Quiz 1
Your Quiz will have 3 questions, one from each of three sections given here.
Please come with sufficient papers to write your answers.
No books, smart phones are allowed. Maximum marks is 30.
Section A
1. (10 points) Consider the problem of determining a DFA and a regular expression are
equivalent. Express the problem as a language and show that it is decidable.
2. (10 points) Let ALLDF A = {hAi| A is a DFA and L(A) = Σ∗ }. Show that ALLDF A is
decidable.
3. (10 points) Let CCF G = {hG, ki| G is a CFG and L(G) contains exactly k strings where
k ≥ 0 or k = ∞}. Show that CCF G is decidable.
4. (10 points) Let A = {hR, Si|R and S are regular expressions and L(R) ⊆ L(S)}. Show
that A is decidable.
Section B
1. (a) (5 points) Show that the solution of T (n) = T (d n2 e) + 1 is O(log n).
(b) (5 points) Use master method to show that the solution to the binary-search re-
currence T (n) = T ( n2 ) + Θ(1) is T (n) = Θ(log n).
2. (a) (5 points) Show that the solution of T (n) = 2T (b n2 c + 17) + n is O(n log n).
(b) (5 points) Use a recursion tree to determine a good asymptotic upper bound on
the recurrence T (n) = T (n − 1) + T ( n2 ) + n. Use substitution method to verify your
answer.
3. (a) (5 points) Use master method to give tight asymptotic bounds for T (n) = 2T ( n4 ) +
n2 .
(b) (5 points) Use a recursion tree to give an asymptotically tight solution to the re-
currence T (n) = T (n − a) + T (a) + cn where a ≥ 1 and c > 0 are constants.
Section C
1. (a) (5 points) Generalize Huffman’s algorithm to ternary codewords (i.e., codewords
using the symbols 0,1 and 2), and prove that it yields optimal ternary codes.
(b) (5 points) Show how to find the maximum spanning tree of a graph, that is, the
spanning tree of largest total weight.
2. (a) (5 points) Let G = (V, E) be a weighted graph with a distinguished vertex s and
all edge weights are positve and distinct. Is it possible for a tree of shortest paths
from s and a minimum spanning tree in G to not share any edges? If so, give an
example. If not, give reason.
Algorithms Questions for Quiz 1 - Page 2 of 2 28th August
3. (a) (5 points) Suppose that a data file contains a sequence of 8-bit characters such that
all 256 characters are about equally common: the maximum character frequency is
less than twice of the minimum character frequency. Prove that Huffman coding in
this case is no more efficient than using an ordinary 8-bit fixed-length code.
(b) (5 points) Prove or disprove Prim’s algorithm works correctly when there are neg-
ative edges.