struct Node {
struct Node* next;
int val;
};
struct Node* newNode(int value){
struct Node* new_node = (struct Node*) malloc (sizeof(struct Node));
new_node->val = value;
new_node->next = NULL;
return new_node;
}
void addToTail(struct Node **root, int value){
struct Node* new_node = (struct Node*) malloc (sizeof(struct Node));
new_node->val = value;
new_node->next = *root;
*root = new_node;
}
void traverse(struct Node* ref){
struct Node* tmp = ref;
while(tmp!= NULL){
printf("%d\n", tmp->val);
tmp = tmp->next;
}
}