Chapter 20Programming Problems Using Linked List
20.1 Queues
The function List_insert in Section 19.3 always inserts the new value at the beginning of the list. If we always delete nodes from the front of the list, then the linked list is a stack. In this problem, we change the insert function so that (1) the first inserted value is at the beginning of the list and (2) the value inserted most recently is at the end of the list. If we still remove elements from the beginning of the list we have created a queue, like a line at a store waiting for service.
Get Intermediate C Programming, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.