Question: Need help for the following assignment in C: Program Summary You're to create a program that implements both a stack and a queue, and processes

Need help for the following assignment in C:

Need help for the following assignment in C: Program Summary You're to

Program Summary You're to create a program that implements both a stack and a queue, and processes commands allowing the user to manipulate these structures. Since your program will have two distinct structures, it will operate in two possible modes: stack mode; and queue mode. In stack mode you're working with the stack, and in queue mode you're working with the queue. The program should start in stack mode. Legal commands are as rollows: S print the current contents of the stack on one line, separated by spaces, with the top of the stack at the left (don't show the sentinel); and then set the current mode to stack mode (so if you're already in stack mode, "s" just prints the stack) q print the current contents of the queue on one line, separated by spaces, with the head of the queue on the left (don't show the sentinel); and then set the current mode to queue mode (so if you're already in queue mode, "q" just prints the queue) Any integer - push onto the stack (if you're currently in stack mode); or insert at the tail of the queue (if you're currently in queue mode) . p either pop the top of the stack (stack mode) or remove the item at the head of the queue (queue mode) and print the item popped or removed (not the entire stack or queue) Q exit the program (be sure to free all memory!) anything else should give a help message. Details Implement the stack using a linked list; implement the queue using a second linked list (so you'll have two sentinel nodes, each pointing to a different linked list). You should use these lists as described in class (summarized below) For the stack, push new elements by adding a node immediately after the sentinel, and pop from the same location. For the queue, the head is the node immediately after the sentinel, and the tail is at the far end of the list

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!