Sie sind auf Seite 1von 5

NAME:

Advanced Algorithms, Fall 2010


Prof. Bernard Moret

Entrance Test
This test is atypical of the course, in that it is in-class and consists mostly of short, multiplechoice questions. Its main purpose is to assess your level of knowledge as we begin the course. You have 2.5 hours to complete this test, which has 12 questions. The questions are grouped by their style of answers: some ask for crossing out wrong choices, some for picking the right answer, some for computing values, and some for describing an algorithm.

On this page, questions ask for short written answers. Question 1. Order the following functions in increasing order by their asymptotic growth rate (write 1 next to the entry with the slowest growth rate, all the way to 6 next to the entry with the fastest growth rate). n3 ( n+1 )n n nlog n 2
n

(log n)log log log n 4log2 n

Question 2. You sample n items with replacement n times; in other words, you end up with n samples, but some of the items may not appear in your sample and some may appear more than once. What is the expected number of distinct items among your n samples?

Question 3. A Boolean clause of length k over n variables is a disjunction (Boolean OR) of k literals, where each literal is either a variable or its complement and all k variables appearing in the clause are distinct. You assign each of the n variables a truth value (true or false) chosen uniformly and independently at random; an assignment of truth values to the variables is said to satisfy a clause if the Boolean formula represented by the clause evaluates to true when replacing its variables by their assigned values. What is the probability that such an assignment satises a given clause of length k? If you had m such clauses, what would be the expected number of clauses satised by such an assignment?

Question 4. Solve the following recurrences in ( ) terms. 1. f (n) = 5f (n 1) 6f (n 2) with f (1) = 1, f (2) = 2 2. f (n) = 3f (n 1) 2f (n 2) + 5n

On this page, questions feature a number of assertions; cross out all erroneous ones. Question 5. klog2 n = nlog2 k
1 limn (1 n )n = 1 e

nk = O(kn ) 3n = O(2n ) (log n)log n = O(n2 ) Question 6. In a (rooted) full binary tree, every node has either zero or two children. Viewed as a graph, such a tree (if it has at least two leaves) has one vertex of degree 2 (the root), some vertices of degree 3 (the internal nodes other than the root), and some vertices of degree 1 (the leaves). A rooted full binary tree cannot have an odd number of leaves. A rooted full binary tree on n leaves has n 1 internal nodes. In a rooted full binary tree, the number of edges connecting two internal nodes (root included) is twice the number of edges connecting to a leaf. The longest path in a rooted full binary tree on n leaves has length n. Question 7. Given an undirected graph with positive edge lengths, you build the tree of shortest paths from some node x to all other nodes. Note that this tree may or may not be unique. An edge of minimum length in this graph for each x, belongs to every such tree of shortest paths for each x, belongs to some such tree of shortest paths for some x, belongs to every such tree of shortest paths for some x, belongs to some such tree of shortest paths need not belong to any such tree

On this page, questions include a choice of answers, of which exactly one is correctcircle it. Question 8. You are given two ordered lists of distinct items, each of length n; note that all 2n items are distinct. You are to merge the two lists, respecting the ordering in each, but otherwise free to choose. How many dierent orderings could you produce?
(2n)! n!

n!
2n n n 2

2(n2 ) Question 9. You want to sort all n text records in Googles database according to their rst 5 characters (its Google, so n is very large, but you have enough memory available). You can do such sorting in (1) time (log n) average time (n) time (n log n) time Question 10. The recurrence relation f (n) = 6f (n/3) 9f (n/9) + n log n with f (1) = f (2) = 1 has for solution f (n) = (n log n) f (n) = (n(log n)2 ) f (n) = (n(log n)3 ) f (n) = (n(log n)4 ) f (n) = (n2 log n) f (n) = (n2 (log n)2 ) f (n) = (3n )

On this page, you are asked to design algorithms. Using the space provided on the page, describe your algorithms concisely in English (using symbols as needed) and analyze them. Question 11. You are given a convex polygon of n vertices. (A convex polygon can be though of as a closed, non-self-intersecting, polygonal line where the internal angle at every vertex cannot exceed . Familiar gures such as triangles, rectangles, etc., are all convex polygons.) The polygon is given to you by the list (in perimeter order) of its vertices, each vertex given by a pair of positive, nonzero integers. Design an algorithm that runs in O(n) time and decides whether some point p = (x, y) (where x and y are also positive, nonzero integers) lies inside the polygon.

Question 12. Suppose you are allowed to make one (and only one) call to a routine that solves the following question: given the set S = {1, 2, 3, . . . , n} (just given by the value n) and a collection of 3-subsets of S, C = {C1 , C2 , . . . , Ck }, where each Ci contains exactly three elements of S and such that the union of all Ci s is equal to S, nd the smallest subcollection C C (i.e., the one with the fewest 3-subsets) such that its union is still equal to S. Show how to use this routine (with just one calla bit like the mythical one phone call when arrested by the police!) to solve this problem in linear time (except for whatever time the one call will takethat is not your worry, since you do not control it). You are given an undirected graph G = (V, E), where V is the set of vertices and E the set of edges, and a subset V V , does G have a spanning tree (a tree formed of a subset of the edges of G that spansconnectsall vertices in V ), the leaves of which are precisely the vertices of V ?

Das könnte Ihnen auch gefallen