# Homework Assignment #1

#### Due by fax to 413-545-1249, attention "Prof. Barrington", by 4:00 pm EST Friday 3 March 2006

There are five questions for 100 total points. All are based on lectures 1-4, and thus on Chapters 1 and 2 and sections 3.1 and 3.2 of the Adler notes.

Students are responsible for understanding and following the academic honesty policies indicated on the course main page.

• Problem 1.1 (30): In this problem you are to use the Master Theorem to analyze the running time of two variants of Mergesort.

• (a,10) In this first variant the list is divided into three equal-sized pieces, each of the three pieces are recursively sorted, and the pieces are merged.
• (b,20) The second variant is similar except that there are now √n pieces with √n elements each. First analyze the running time assuming the following simple merge procedure is used: scan the smallest remaining element of each list and choose the smallest to put into a merged list. Then redo the analysis assuming that each of the current-smallest elements is put in a priority queue and replaced from its sublist when put into the merged list. Assume that the insert and remove-min operations on a queue with m elements can each be done in O(log m) time.
• Problem 1.2 (30): Let G be a weighted undirected graph where the weights are each real numbers between 0 and 1. Let T be a minimum spanning tree for G. For each of the following three re-weightings of G, determine whether T is still necessarily a minimum spanning tree for the reweighted graph. (Remember that a weighted graph may have more than one MST if there are two or more with the same total weight.) Either prove that T must be an MST for any G, or give an example of a G for which it isn't an MST.

• (a,10) In the graph G1, each weight w is replaced by the sine of w (where w is considered to be given in radians).
• (b,10) In the graph G2, each weight w is rounded up to the next integer.
• (c,10) In the graph G3, each weight is multiplied by ten and then rounded up to the next integer.
• Problem 1.3 (20): (Two exercises stolen from CLRS)

• (a,10) On page 12 of the Adler notes there are three results of Pan quoted on the number of scalar multiplications needed to multiply matrices of three specific sizes. Determine the asymptotic running time of Strassen-like algorithms to multiply n by n matrices for general n, using each of these three base cases. Which one is asymptotically best?
• (b,10) Using the Strassen algorithm, what is the time needed (as a function of both n and k) to multiply a kn by n matrix by an n by kn matrix? What about multiplying an n by kn matrix by a kn by n matrix?
• Problem 1.4 (20): (Stolen from Brassard-Bratley (1998), Problem 4.11.2) In this problem we represent an integer polynomial P = a0 + a1x + ... + adxd of degree d by an array of length d+1 containing the coefficients a0...ad. Assume that we can multiply a polynomial of degree i by a polynomial of degree 1 in O(i) time. Using FFT, we can multiply two polynomials of degree i in O(i log i) time.

Given d distinct integers n1,...,nd, there is a unique monic polynomial of degree d such that p(ni) = 0 for each i. "Monic" means that ad = 1. Give an efficient algorithm to compute this polynomial.