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

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. Don’t change them. Only work on Hanoi.java.

Hanoi.java

The recursive solution to the Hanoi problem, recHanoi(), is given. Don’t 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.