node *head, *tail, *temp;
// first allocation
temp = new node;
temp->data = 2;
temp->link = NULL;
head = tail = temp; // be sure to assign head and tail
// second allocation
temp = new node;
temp->data = 4;
temp->link = NULL;
tail->link = temp; // chain our new node to the tail
tail = temp; // now the new node is our new tail
// same as second allocation
temp = new node;
temp->data = 2;
temp->link = NULL;
tail->link = temp;
tail = temp;