Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Files: queue.h, queue.c Define a type process_t that represents a process that has both an identifier (int) and a name (char*). We will be testing
Files: queue.h, queue.c Define a type process_t that represents a process that has both an identifier (int) and a name (char*). We will be testing our queue using items of this type, though we will keep the implementation of the queue more generic. Define a type queue_t that represents a queue that can hold anything (hint, the data in the node must be of type void *). Define a function enqueue (queue_t *queue, void "element) that can adds element to the end of the queue Define a function void * dequeue queue_t *queue) that removes and returns the element at the front of the queue Files: queue_main.c Write a main function that exercises the linked queue by using process_t elements. It must create and add several process_t elements to thoroughly exercise the queue. In order to show this, you must print a one-line description of what must be in the queue along with the contents of the queue in between steps. Files: Makefile Add an entry to your "Makefile" for compiling the linked queue into an executable called "queue" with the command "make queue." Modify your "Makefile" such that the command "make" generates both "caesar" and "queue." You do not have to strictly follow the print format and the enqueue and dequeue patterns, but the below is an example execution of the "queue" program. # This program enqueues three process_t elements and then dequeues all three elements. # We encourage you to write more interesting enqueue/dequeue patterns in your main function. $ ./queue Enqueue: (id: 1, name: A] is enqueued. (id: 1, name: A] Enqueue: [id: 2, name: B] is enqueued. (id: 1, name: A] -> [id: 2, name: B] Enqueue: [id: 3, name: c] is enqueued. (id: 1, name: A] -> [id: 2, name: B] -> [id: 3, name: c] Dequeue: [id: 1, name: A] is dequeued. [id: 2, name: B] -> [id: 3, name: c] Dequeue: [id: 2, name: B] is dequeued. [id: 3, name: C] Dequeue: [id: 3, name: c] is dequeued. (Empty] Files: queue.h, queue.c Define a type process_t that represents a process that has both an identifier (int) and a name (char*). We will be testing our queue using items of this type, though we will keep the implementation of the queue more generic. Define a type queue_t that represents a queue that can hold anything (hint, the data in the node must be of type void *). Define a function enqueue (queue_t *queue, void "element) that can adds element to the end of the queue Define a function void * dequeue queue_t *queue) that removes and returns the element at the front of the queue Files: queue_main.c Write a main function that exercises the linked queue by using process_t elements. It must create and add several process_t elements to thoroughly exercise the queue. In order to show this, you must print a one-line description of what must be in the queue along with the contents of the queue in between steps. Files: Makefile Add an entry to your "Makefile" for compiling the linked queue into an executable called "queue" with the command "make queue." Modify your "Makefile" such that the command "make" generates both "caesar" and "queue." You do not have to strictly follow the print format and the enqueue and dequeue patterns, but the below is an example execution of the "queue" program. # This program enqueues three process_t elements and then dequeues all three elements. # We encourage you to write more interesting enqueue/dequeue patterns in your main function. $ ./queue Enqueue: (id: 1, name: A] is enqueued. (id: 1, name: A] Enqueue: [id: 2, name: B] is enqueued. (id: 1, name: A] -> [id: 2, name: B] Enqueue: [id: 3, name: c] is enqueued. (id: 1, name: A] -> [id: 2, name: B] -> [id: 3, name: c] Dequeue: [id: 1, name: A] is dequeued. [id: 2, name: B] -> [id: 3, name: c] Dequeue: [id: 2, name: B] is dequeued. [id: 3, name: C] Dequeue: [id: 3, name: c] is dequeued. (Empty]
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started