CS513 Spring 2020 Design and Analysis of Data Structures and Algorithms
CS513 Spring 2020 Design and Analysis of Data Structures and Algorithms
Algorithms
Jie Gao∗
February 9, 2020
Due February 23rd 9pm. Each problem, unless specified otherwise, has a maximum of 10
points. Avoid too many details. A succinct and clean proof is the best. You may use the algorithms
we covered in class without referring to the details.
Homework 2
Assignment Problems
1. For any two sets X and Y of integers, the Minkowski sum X + Y is the set of all pairwise sums
{x + y|x ∈ X, y ∈ Y }.
Show that if v is a column vector of length n = 2k , then the matrix-vector product Hk v can
be calculated using O(n log n) operations. Assume that all numbers involved are small enough
that basic operations such as addition and multiplication take unit time.
3. Sorting random numbers. Given n real numbers uniformly randomly sampled from [0, 1], we
want to sort them efficiently. We wish to use hashing. Create n buckets. Bucket i holds
numbers in range [(i − 1)/n, i/n]. Place the numbers in these buckets. Now for the numbers
placed in each bucket sort them using bubble sort. Analyze the expected running time of the
algorithm.
∗
Department of Computer Science, Rutgers University, jg1555@cs.rutgers.edu.
1
4. A family H of has functions is uniform if choosing a hash function uniformly at random from H
makes every hash value equally likely for every item in the universe. That is, if h is uniformly
randomly chosen from H, for all x and i,
Prob{h(x) = i} = 1/m
A family H of has functions is universal if choosing a hash function uniformly at random from
H makes the probability of collision as small as possible. That is, if h is uniformly randomly
chosen from H, for all x 6= y,
Prob{h(x) = h(y)} = 1/m
A family H of has functions is strongly universal (or pairwise independent) if choosing a hash
function uniformly at random from H, for all x 6= y,
(a) Describe a set of hash functions that is uniform but not universal. (5pts)
(b) Describe a set of hash functions that is universal but not strongly universal. (5pts)