Study Exam
Study Exam
Study Exam
1. Write the recursive relation for the running time of the algorithm given to solve ’Tower
of Hanoi’ problem and provide a solution for it.
Solution:
T (n) = 2T (n − 1) + 1.
The solution is T (n) = 2n − 1. This can be shown by using induction on n. The proof
by induction should consist of two steps: 1) base case, 2) inductive case, typically
making use of the information called inductive hypothesis. The detailed solution is
in the reading for ’Solving Recurrences’.
Use a recursion tree, to show that T (n) = O(n log n). Show all your work.
Solution: (See class notes or the slides or the reading on ’Solving recurrences’ for
the solution.)
4. Consider the recurrence relation T (n) = 2T (n/2) + n/ log n. Use a recursion tree, to
show that T (n) = Θ(n log log n).
1
√
5. Consider the recurrence relation T (n) = T ( n) + 1. Use a recursion tree to show
√ √
that T (n) = Θ(log log n). Similarly, if T (n) = nT ( n) + n, show that T (n) =
Θ(n log log n).
6. • Karatsuba’s multiplication algorithm has running time T (n), where T (n) = 3T (n/2)+
n. Use a recursion tree to show that T (n) = Θ(nlog2 3 ).
• Let T (n) = 2T (n/2) + n/ log n. Show that T (n) = Θ(n log log n).
• Let T (n) = 4T (n/2) + n/ log n. Show that T (n) = Θ(n2 ).
7. Q1: Argue briefly why the recursive relation for the running time of the Tower of Hanoi
problem is T(n) = 2T(n-1)+1 for n at least 1, in an recursive algorithm provided in class.
In other words, explain why we cannot do better with a shorter running time or why not
more running time is needed in the given recursive algorithm.
9. In the conflict-free class-scheduling problem, a) prove that at least one maximal conflict-
free schedule includes the class that finishes first.
b) prove that the greedy algorithm that picks the non-conflicting class that finishes
first from the available classes outputs an optimal schedule (with maximal number of
classes).
2
Solution: See reading on greedy algorithms.
10. Design a Turing machine by writing the steps of the algorithm (no diagram asked) exe-
cuted to accept if the input is in the language A and reject otherwise.
Solution: All of the questions are examples in Sipser’s book (see webpage) Chapter
3 and our slides. Therefore, you can find the solutions there.
11. Besides these, I may give you a Turing machine with its diagram and an input, where
you are supposed to list all configurations showing the executions of the Turing machine
and the final state (accept or reject). (See Sipser’s book, exercises 3.1 and 3.2)
12. Show that if the language L and its complement L̄ are recognizable, then L is decidable.
(Lecture Notes)
14. Show that AT M is not a decidable language. (pg.174 in Sipser’s book/ Lecture Notes)
17. Let L be an undecidable language. Is it possible that both L and L̄ (the complement of L)
are recognizable. If yes, give an example. If no, give a short proof. (pg.181 in Sipser’s
book)
18. What is the maximum independent set problem? What is the decision problem equiva-
lent to this problem? (Lecture 7)
19. Show that the maximum independent set problem is in NP. (Lecture 7)
20. What is the minimum vertex cover problem? What is the decision problem equivalent to
this problem? (Lecture 7)
3
21. Show that the minimum vertex cover problem is in NP. (Lecture 7)
22. Show that the independent set problem can be reduced to the clique problem in polyno-
mial time? How big is this polynomial in the worst-case? (Lecture 7)
23. Show that the independent set problem can be reduced to the vertex cover problem in
polynomial time? How big is this polynomial in the worst-case? (Lecture 7)