CPSC 212-1 Name: _____________________________ Quiz #1 January 17, 2001 Closed books. Closed notes. Calculators OK. 20 points. 10 minutes. Weight of each question in parentheses. Please use a pencil. For more space, use the back of the sheet. 1. (8) Evaluate each of the following sums: (a) 1 + 2 + 3 + ... + n = n(n+1)/2 (b) 1 + 2 + 3 + ... + (n+1) = (n+1)(n+2)/2 (c) 27 + 30 + 33 + ... + 3n = 3(9 + 10 + ... + n) = 3(n(n+1)/2 - 8*9/2) = 3(n(n+1)/2 - 36) (d) 1 + 4 + 9 + ... + n2 = n(n+1)(2n+1)/6 2. (8) Evaluate each of the following. Use the letters "A", "Q", "P", "K", "W", "L", "R", "M", "G", "T", "V" and "E" where appropriate. 4K = 2^12 64T = 2^46 8P = 3^53 512E = 2^69 3. (4) What is the order of complexity of each of the following: Quicksort on an array of N elements O(n^2) worst case, O(n log n) average case Finding the median value (50th percentile) of a sorted set of N values O(1) Finding the 10th largest value in an unsorted set of N values (assume N>10) O(n) Assume that an int NxN array is checkerboard-colored (some elements are considered "red", the other are "black"). What is the complexity of taking the sum of all of the "red" elements. O(n^2)