LAST NAME: FIRST NAME: 30 points total. Note: * is times, ^ is exponentiation, + is plus, - is minus, / is division, all log's are base 2 (1) 2 points. Put the following in order from "smallest" to "greatest" - EXPSPACE, NP, P, EXP, PSPACE. P, NP, PSPACE, EXP, EXPSPACE (2) 2 points each. For each of the following, say whether the problem is in P, NP, or EXP, and explain why (if in P, what is the polynomial time algorithm; if in NP, what is the polynomial time verifier/checker; if in EXP, how is the solution determined in exponential time). 2a. Shortest path: can you get from one vertex to another in a graph in a given number of steps. P, Dijsktra's alg, O(#vertices^2 * #edges) 2b. Longest path: is there a path that is at least a given number of steps from one vertex to another in a graph. NP 2c. Graph coloring: given a graph and a number k, can the graph be colored with k colors so that vertices that share an edge have different colors. NP Example of a not-in-NP problem... * who wins nxn chess (or other games) - those tend to be PSPACE-complete? (3) 4 points. Given a message m, and public key n and e, how is the message encrypted in RSA? What is the running time as a function of the number of bits in m, n, ane e? encrypted as m^e mod n (where ^ means exponential, not xor). running time = 1 mod exp. running time #bits * bit-time(multiplication) = #bits^3 (4) 4 points. Whatever your project is, explain it in the space given here. First state what problem you are looking at, and give an example. Then explain what algorithm you are looking at, and some of the interesting properties of the algorithm (e.g., it is polynomial time, or it is really good on ___ type of inputs, or ...) (5) 4 points. Pick a primality testing algorithm. Write down the name of it, and write down pseudocode for it. Then say what the running time of the algorithm is as a function of the number of bits? Trial division... input: is x prime? algorithm: for i = 2 up to sqrt(x) if i divides x, return "not prime" if no i divides x, return "prime" // idea: try each possible divisor from 2 up to sqrt(x) Running time: bit-time-for-division * 2^(#bits/2) = #bits^2 * 2^(#bits/2) Running for Fermat test: bit-time-for-mult * #bits * how-many-trials (6) 3 points. Prove the following. For any non-negative integer a and any positive integer b, gcd(a,b) = gcd(b, a mod b) In the book... (7) 1 point each. Memorize formulas (where ^ is exponentiation)... 7a. 1 + 2 + 3 + 4 + ... + 300 = 300*301/2 7b. 1 + 2 + 4 + 8 + ... + 2^20 = 2^21 - 1 7c. log(2^16) = 16 * log(2) = 16 7d. How many bits in 1 gigabyte? 8 * 1 billion, or 8 * 2^30 7e. (10^4)^5 / (10^5) = 10^20 / 10^5 = 10^15 (8) 2 points. On your 1 gigahertz computer, how long does it take to do each of the following 8a. Run O(n) algorithm, for problem where n = 1 million ~ 10^6 / 10^9 = .001 seconds 8b. Run O(n log(n)) algorithm, for problem where n = 1 million ~ 10^6 * 20 / 10^9 = .02 seconds 8b. Run O(n^2) algorithm, for problem where n = 1 million ~ 10^12 / 10^9 = 1000 seconds 8c. Run O(n^3) algorithm, for problem where n = 1 million ~ 10^18 / 10^9 = 10^9 seconds = 300 years