Theory of Algorithms Exam June 1st, 2016
1. Letf(n) = 3√
n+ 2n2+ 2log2n. Give an appropriate constantcand threshold valuen0 and show using them that f(n) =O(n3).
2. Consider grammar A → aAB | BC B → b BC → Aa | B. Is this grammar context-free? If not, then make it context-free so that the result generates exactly the same words as the original one does.
3. Is it possible that following pictures show red-black trees? (Leaves are not shown, black circle means black vertex, white square denotes red vertex.)
4. Let the alphabet be Σ ={0,1}, furthermore letM be an incomplete finite automaton that has 5 states and 8 transitions. If we make it complete using the procedure studied in class, then how many states and how many transitions will the result have?
5. Let array A store n elements. How can a pair of indices i6=j be found using O(nlogn) comparisons that satisfies |A[i]−A[j]|<100?
6. Is it in Por is it NP-complete the version of BinPackingproblem, where each weight is either 1/4 or 4/5?
7. The edges of simple graph G(V, E) are weighted. We want to find a subsetX ⊆E of maximum total weight such that every vertex in V is incident with at most 3 edges from X. Formulate this problem as an integer programming problem.
8. During summer there will many festivals be held that are interesting for us, unfortunately, there are overlaps between the dates of some of the festivals. If we go to a festival, then we want to stay there from the first day till the last day, however, the day after the last day of a festival we may immediately go to another festival. There are f festivals in question, the start and end days of each are known. Our goal is to spend as many days on festivals as possible, that is we want to maximize the number of days spent on festivals. Give an O(f2) time algorithm that solves this problem. (hint: formulate the problem as a graph theory question involving DAG’s.)
Results without proper reasoning receive no credit. It is forbidden to seek or give help from/to others, as well as usage of any electronic device, or written notes. Mobile phones must be switched off.