Design and Analysis of Algorithms Neal Young
Computer Science 45
Midterm Exam, due in class Monday, May 12, 1997
Do three of the following problems. You can consult your notes, the text, or me when working on this exam, but please don't consult any other source. If you get stuck on a problem, you can come to me and ``buy'' a hint at the expense of part of the credit for the problem.
Design and analyze an algorithm for the following problem. Your algorithm may be randomized. It should be as efficient as you can make it, in the ``big-O'' sense. Give as complete an analysis as you can. (``Complete'' does not mean overly detailed, it just means that there are no gaps or ``hand waving''.)
Given: Two two-dimensional arrays T[1..n,1..n] and P[1..m,1..m], where and each array entry is a digit in .
Question: Does P occur in T? More specifically, are there an a and a b such that T[i+a,j+b] = P[i,j] for all i and j between 1 and m?
This problem asks you to consider an example of a different style of generating function.
Define .
Read section 27.5 of CLR to understand the lift-to-front algorithm, then give a different analysis of the algorithm. Your analysis should be an amortized analysis based on a potential function. (The challenge here is to design the potential function.)
Professor Bo Zo wanted to assign an exam question on the Pollard-Rho algorithm, but he couldn't understand it. Read section 33.9, to understand Pollard-Rho, then help clear up Bo's questions:
If it doesn't use that assumption, then can't the analysis be improved, because the time to find a factor will be , rather than (an improvement when )?
If it does use that assumption, then how does the algorithm work when applied to a prime power (i.e., with )? If it doesn't work, how do you handle this case?