CS 200, Spring 2015
P1: Implementing Recursion using an explicit Run Time Stack

Due and late dates and times

Overview

The object of this assignment is to implement recursion using an explicit Run Time Stack. Copy the following code into an eclipse project: StackIF.java, StackException.java and Frame.java are given. DO NOT CHANGE THEM. Only work on Hanoi.java.

Hanoi.java

The recursive solution to the Hanoi problem, recHanoi(), is given. DO NOT CHANGE IT. You need to work on the iterative, explicit stack based solution. Start implementing the getCount() and initRTS() methods and the methods implementing the stack operations: push(), pop(), and isEmpty(), as specified in StackIF.java.

Now you are ready to implement rtsHanoi using a Run Time Stack rts. Study lecture 2: 02-stacks slides 18 to 27.

Initially, there is one Frame [state,n,from,to] on rts. Keep popping frames until rts empty. When popping a frame:

Testing and submitting your code

Use the Checkin webserver to exercise and submit your code. Submit your Hanoi.java file.