Computer Science 130BWinter 2007Written Assignment #1Due: 4pm, January 19th, FridayProblem 1In divide-and-conquer, the way a problem is divided into pieces often affects the effectivenessand applicability of the proposed solution. Consider the Towers of Hanoi problem again. Define the originalproblem asHanoi(n, A, B, C),where the first parameter denotes the number of disks, the second parameter the starting peg, the thirdparameter the ending peg, and the last parameter the temporary storage peg.a.Consider the following divide-and-conquer strategy:Hanoi(n, A, B, C)⇒Hanoi(1, A, C, B) +Hanoi(n-1, A, B, C) +Hanoi(1, C, B, A),which divides the original problem intotwoinstances of size 1 andoneinstance of sizen-1. If you thinkthe strategy will work, give the detailed motion sequence for Hanoi(4,A,B,C) and estimate the complexityof the algorithm. If you think the strategy will not work, provide a counterexample.b.Ifn= 2k, consider the following divide-and-conquer strategy:Hanoi(n, A, B, C)⇒Hanoi(n/2, A, C, B) +Hanoi(n/2
This is the end of the preview.
access the rest of the document.