Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
82 views

CS513 Spring 2020 Design and Analysis of Data Structures and Algorithms

This document outlines 4 problems for a homework assignment on data structures and algorithms. 1. Describe algorithms to compute the number of elements in the Minkowski sum of two sets in O(n^2 log n) time and O(M log M) time where M is the largest element value. 2. Show that the matrix-vector product of a Hadamard matrix Hk and a vector v can be computed in O(n log n) time where n = 2^k. 3. Analyze the expected running time of a algorithm that sorts random numbers by placing them in buckets and sorting each bucket with bubble sort. 4. (a) Describe a set

Uploaded by

bala_thegame
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
82 views

CS513 Spring 2020 Design and Analysis of Data Structures and Algorithms

This document outlines 4 problems for a homework assignment on data structures and algorithms. 1. Describe algorithms to compute the number of elements in the Minkowski sum of two sets in O(n^2 log n) time and O(M log M) time where M is the largest element value. 2. Show that the matrix-vector product of a Hadamard matrix Hk and a vector v can be computed in O(n log n) time where n = 2^k. 3. Analyze the expected running time of a algorithm that sorts random numbers by placing them in buckets and sorting each bucket with bubble sort. 4. (a) Describe a set

Uploaded by

bala_thegame
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

CS513 Spring 2020 Design and Analysis of Data Structures and

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 }.

(a) Describe and analyze an algorithm to compute the number of elements in X + Y in


O(n2 log n) time.
(b) Describe and analyze an algorithm to compute the number of elements in X + Y in
O(M log M ) time, where M is the largest absolute value of any elements of X ∪ Y .

2. The Hadamard matrix H0 , H1 , H2 , · · · , are defined as follows:

(a) H0 is the 1 × 1 matrix [1].


(b) For k > 0, Hk is the 2k × 2k matrix
 
Hk−1 Hk−1
Hk =
Hk−1 −Hk−1

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,

Prob{h(x) = i ∧ h(y) = j} = 1/m2

(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)

You might also like