5.1 Stack
struct Stack
{
char ch; //stack identifier
int top; //stack top pointer
float size[MAX]; //array containing size of each disk
int color_index[MAX]; //array containing index to color of disks
float x_pos; //position of stack (pole)
float y_pos[MAX]; *//position of disk in the stack (y position)
*
};
5.2 Linked List **
struct Record
{
char src; //source pole
char dest; //destination pole
struct Record next; //pointer to next node*
};
5.3 Detailed Implementation
The Tower of Hanoi algorithm is initially run and the movement of disk at each step is recorded in the linked lists. This linked list is then traversed by giving some constant delay between each visit to a node and the stack contents after each visit is updated. After each update the contents of all the three stacks are read and displayed. Thus it is possible to see the step by step disk movement in solving the tower of Hanoi problem.