CMSI 282
Final Exam

The test is open-everything with the sole limitation that you neither solicit nor give help while the exam is in progress.

Do any ten problems. Write the numbers of the problems you want graded in the obvious place below. Show me how talented, articulate, and mathematically mature you are.

ProblemYou gotOut of
 
 
 10
 
 
 10
 
 
 10
 
 
 10
 
 
 10
 
 
 10
 
 
 10
 
 
 10
 
 
 10
 
 
 10
TOTAL
 
 100
  1. Prove that:
    alogbc = clogba
    
  2. One of the Freshmen tried to use the Master Theorem to solve

    T(n) = 1 if n=1,

    T(n) = 2T(n-1)+1, otherwise.

    Assuming you were kind and helpful, what would you tell this poor student? And, by the way, since kindness does not involve flat-out telling the student the answer, tell me, instead, how do you express T in Θ-notation?

  3. So you're reading this fancy paper on algorithms and you see a small snippet of code. It's a recursive algorithm, with a small enough number of recursive calls that you can count them on one hand. The paper says that complexity of the algorithm is

    obviously Θ(n2.32192809)

    Explain the structure of the algorithm and how this "obvious" value was obtained.

  4. Give the complexity function T for the following code fragment, both as (a) a recurrence relation and (b) in closed form using Θ-notation.

        public static long f(List a) {
            if (a.size() > 1) {
                f(a.subList(0, a.size()/3));
                f(a.subList(a.size()/3, 2*a.size()/3));
                f(a.subList(2*a.size()/3, a.size()));
                for (int i = 1; i <= n; i *= 2)
                    for (int j = 1; j <= i; j++)
                        System.out.println("*");
                    }
                }
            }
        }
    
  5. Consider the undirected, weighted graph with vertices {A, B, C, D, E, F} and edges (A,B,5), (B,D,6), (B,C,1), (A,C,3), (F,E,2), (D,E,2), (E,C,8), (A,E,1), and (C,D,1). Again, please note the graph is undirected.
    1. Draw the graph.
    2. Give a smallest vertex cover.
    3. Give a Minimum Spanning Tree.
    4. Use Dijkstra's algorithm to find a shortest path from F to B?
    5. Which edges are bridges?
    6. Which nodes are articulation points?
    7. Is there a Hamilton Cycle? If so, name one. If not, why not?
    8. Is there a Hamilton Path? If so, name one. If not, why not?
    9. Is there an Euler Path? If so, name one. If not, why not?
    10. What is the chromatic number of this graph?
    11. Extra Credit: Solve the TSP for the graph obtained by removing node F.
  6. An algorithm with complexity function T(n) = n4 can process a 16-element list on our PC in 256 seconds.
    1. How much time is needed to process a 32-element list?
    2. If we ran the algorithm on a machine that was 1024 times faster than our PC, how large of a list could we process in one day? (Note 1 day = 86400 seconds)
    3. If we needed a computer that could process 100 elements per minute, how much faster than our original PC does this computer need to be?
  7. Show the progress of (a) radix sort (base 10) and (b) selection sort, applied to the array [245 221 103 99 214 117 288].
  8. The following characters were inserted into an initially empty binary min heap, in this order: Z R S Q P L K I A C. Then two remove_min operations were performed. Show the resulting min-heap. (If you think you might get this wrong, maximize your partial credit capability by showing a few intermediate snapshots.)
  9. Give a Huffman Encoding for the string "THE CAT ATE THAT HAT". Hint: There are 6 T's, 3 H's, 2 E's, 4 spaces, 1 C, and 4 A's. That's 20 characters total.
  10. Here are some randomization questions.
    1. Is bozosort an example of a Las Vegas or Monte Carlo algorithm?
    2. Is bogosort an example of a Las Vegas or Monte Carlo algorithm?
    3. Why is it a good idea to randomize (scramble) an array before applying quicksort?
    4. What does it mean for a random number generator to be cryptographically secure?
    5. If you wanted to determine the probability that at least two people in a randomly selected group of thirty had the same birthday, you could run hundreds of trials and keep track of all the simulation results. Is this a Las Vegas or Monte Carlo algorithm?
  11. Generate the ciphertext for the message "RATSRULE" using the bifid algorithm with key "MICEAREFREAKINGSTUPID". Lay out the key row by row, left to right within each row, as is the convention. Show the entire derivation.
  12. Write a Java method to generate three values N, e, and d, that can be used for an RSA key pair. Make N a 512-bit number. For simplicity, you can let e=3. Write nice, short, elegant code.