in the hatoi tree function
why do need "temp" variable
Code:
#include<stdio.h>
#include<stdlib.h>
typedef struct node Node;
struct node{
int width;
int source;
int target;
int temp;
Node* left;
Node* right;
};
Node * hanoi_tree(int width, int source, int target, int temp){
Node *root;
?? 1 ?? ;
root = (Node*)malloc(sizeof(Node));
root -> width = width;
root -> source = source;
root -> target = target;
root -> temp = temp;
?? 2 ?? = hanoi_tree( ?? 3 ?? );
?? 4 ?? = hanoi_tree( ?? 5 ?? );
?? 6 ??;
}
void print(Node* root){
?? 7 ??;
print(root -> left);
printf("Move disk from tower %d to tower %d\n", ?? 8 ??);
print(root ->right);
}
void main(){
Node *tree;
tree = hanoi_tree( 4, 1, 2, 3);
print(tree);
}