hw1 - Computer Science 130B Winter 2007 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 2007 Written Assignment #1 Due: 4pm, January 19th, Friday Problem 1 In divide-and-conquer, the way a problem is divided into pieces often a±ects the e±ectiveness and applicability of the proposed solution. Consider the Towers of Hanoi problem again. De²ne the original problem as Hanoi ( n, A, B, C ) , where the ²rst 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.

This note was uploaded on 08/06/2008 for the course CS 130B taught by Professor Suri during the Winter '08 term at UCSB.

Ask a homework question - tutors are online