CS 161 - Algorithms Homework 1, 25 Points
Due: Monday, January 13, 2014, 11:55pm

Please submit your solutions in pdf format via dropbox on eee.
Note: scanned copies of handwritten solutions will not be graded. Solutions must be typed.

  1. 5 points. Problem R-1.6 from Goodrich-Tamassia.
  2. 5 points. Problem R-1.12 from Goodrich-Tamassia.
  3. 5 points. Problem C-1.14 from Goodrich-Tamassia.
  4. 5 points. Suppose you are writing a simulator for a single-elimination sports tournament (like in NCAA Division-1 basketball). There are n teams at the beginning of the tournament and in each round of the tournament teams are paired up and the games for each pair are simulated. Winners progress to the next round and losers are sent home. This continues until a grand champion team is the final winner. Suppose your simulator takes O(log n) time to process each game. How much time does your simulator take in total?
  5. 5 points. Given an integer k > 0 and an array, A, of n bits, describe an efficient algorithm for finding the shortest subarray of A that contains k 1's. What is the running time of your method?