Homework 1 Tower's of Hanoi

Document Sample
Homework 1  Tower's of Hanoi Powered By Docstoc
					Homework 1: Tower’s of Hanoi
100pts (10% of homework grade)
Due: June 6th 11:59 pm.
Late penalty: 20 pts / day

The tower’s of Hanoi puzzle is very ancient. The game board consists of 3 pegs, A, B,
and C. A has N disks on it. The bottom disk is bigger than the disk on top of it, which is
bigger than the disk on top of it, etc. To solve the puzzle you must move all the disks to
another peg. The rules are that you may only move one disk at a time, and that you may
never place a larger disk on top of a smaller disk.

Implement a recursive solution to this puzzle in C/Java code, then in MIPS assembly
language as a program for the SPIM simulator.

Hint: to move N disks from peg A to peg C first move N-1 disks to peg B then move 1
disk from peg A to peg C then move N-1 disks from peg B to peg C.


On the SPIM console the output shall be the list of moves required to solve the puzzle


Move 1: A - B
Move 2: A - C
Move 3: B – C
Move X: A-C

Your program should be self contained (i.e. have a main procedure) it should run the
towers of Hanoi problem with 7 disks.


C/Java code version: 10 points
Follows procedure calling conventions: 20 points
Proper comments: 20 points
Assembles: 10 points
Runs w/o errors: 20 points
Runs correctly: 20 points

Shared By:
pptfiles pptfiles