CS 201 - 9/23/14 /* code for pop - not "top&pop" */ void removeFromFront (listNode** hd) { // set up tmp to refer to the first node // in the list listNode* tmp; tmp = *hd; if (isEmpty( tmp ) == FALSE) { // set head to point to second node *hd = tmp->next; // free the removed node free (tmp); } } To move from stack to queue linked list operations - we only need to modify the addToList operation. When adding to a queue we need to add at the end of the list rather than the front of the list. To get to the end of the list, we can traverse through the list to the end. First let us write code that will traverse through the list printing all of the items stored in the list. // the call from main() traverseAndPrint (head); void traverseAndPrint (listNode* hParam) { listNode* curr = hParam; while (curr != NULL) { printf ("%d, " , curr->elem); curr = curr->next; } printf ("\n"); } // the call from main() int listLength = traverseAndCount (head); int traverseAndCount (listNode* hParam) { int nodeCount = 0; listNode* curr = hParam; while (curr != NULL) { nodeCount++; curr = curr->next; } return nodeCount; } Insert At the End of the list // the call from main() addToEnd (&head, value); void addToEnd (listNode** hd, int val) { listNode* curr = *hd; listNode* prev = NULL; while (curr != NULL) { prev = curr; curr = curr->next; } listNode* tmp = (listNode*) malloc (sizeof(listNode)); tmp->elem = val; tmp->next = NULL; if ( prev != NULL ) prev->next = tmp; else *hd = tmp; }