node *addNode (node *head, int value){
node *x = new node;
x -> key = value;
x -> next = NULL;
if (head == NULL){
head = x;
}
else {
if (head -> next == NULL){
head -> next = x;
}
else {
node *temp = head;
while (temp -> next != NULL){
if (temp -> next == NULL) {
temp -> next = x;
}
temp = temp -> next;
}
}
}
return head;
}