hw1 - Computer Science 130B winter 2012 Written Assignment...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
Computer Science 130B winter 2012 Written Assignment #1 Due: 4pm Friday, January 20th Problem 1 In divide-and-conquer, the way a problem is divided into pieces often affects the effectiveness and appli- cability of the proposed solution. Consider the Towers of Hanoi problem again. Define the original problem as Hanoi ( n, A, B, C ) , where the first parameter denotes the number of disks, the second parameter the starting peg, the third parameter 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 into two instances of size 1 and one instance of size n - 1 . If you think the strategy will work, give the detailed motion sequence for Hanoi(4,A,B,C) and estimate the complexity of the algorithm. If you think the strategy will not work, provide a counterexample. b.
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.
Ask a homework question - tutors are online