Description
Homework Description: Tower-Of-Hanoi
The Tower of Hanoi is a mathematical puzzle. It consists of three poles and a number of disks of different sizes which can slide onto any poles. The puzzle starts with the disk in a neat stack in ascending order of size in one pole, the smallest at the top thus making a conical shape.
The puzzle has the following two rules:
1. You can’t place a larger disk onto a smaller disk
2. Only one disk can be moved at a time
#define STACK_BLOCK_SIZE 10
typedef struct { data_type * array; int currentsize; int maxsize} stack;
int push(stack * s, data_type d); /* the stack array will grow STACK_BLOCK_SIZE entries at a time */
data_type pop(stack * s); /* the stack array will shrink STACK_BLOCK_SIZE entries at a time */
stack * init_return(); /* initializes an empty stack */
int init(stack * s); /* returns 1 if initialization is successful */
Using this, implement a solution to tower-of-hanoi problem without recursion and using stack. Your solver should be able to take any size tower.
Example for size 3:
Example output for size 3:
General Rules:
Obey the style guidelines.
Do not change the provided function prototypes (you will not get any credits).
Your program should work as expected. Do not expect partial credit if your code works only in some cases but not in all cases as expected.
You can ask your questions about the homework by posting on the forum in Teams. Handing in your work:
Hand in your work using the appropriate class Teams assignment site. No
Pack this directory into a zip file named 20180000001_X_Z.zip
When unpacked as above in Ubuntu (version provided in class) it should allow executing the following commands in a shell:
▪ “$make clean” removes everything except makefile, source code (.c ) and other resource files (if any) – all compiling results and intermediate files should be removed.
▪ “$make compile” should compile the code.
▪ “$make run” should run the code along with any parameters needed.




Reviews
There are no reviews yet.