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.
of handwritten solutions will not be graded. Solutions must be typed.
Problem R-1.6 from Goodrich-Tamassia.
Problem R-1.12 from Goodrich-Tamassia.
Problem C-1.14 from Goodrich-Tamassia.
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?
Given an integer k > 0 and an
array, A, of n bits, describe an efficient algorithm
the shortest subarray of A that contains k 1's.
What is the running time of your method?