Question: Exercise 4.e.ii (9 points) Use the given template to complete a C program implementation of a Queue Add comments where necessary, explaining each significant functionality


Exercise 4.e.ii (9 points) Use the given template to complete a C program implementation of a Queue Add comments where necessary, explaining each significant functionality typedef struct _Queue { 1/1 point } Queue; typedef struct _Node { //1 point } Node; Queue* Q_initialize(int i, char* c) { //1 point Input Specifications An integer to set the data type size and a string to represent the name of the data type being stored Expected Return value A pointer, pointing to an initialized Queue. Extra Requirements N/A } bool q_enqueue (Queuet a, void+ v) { //1 point Input Specifications A pointer, pointing to a Queue object and a void pointer, pointing to an element. Expected Return value if the element had been added to the queue successfully, return true. Otherwise return false. Extra Requirements The function should succesfully insert the given element at the end of the queue } void* q_dequeue (Queuet q) { //1 point Input Specifications pointer, pointing to a Queue object Expected Return value A void pointer, pointing to the element that was removed. Extra Requirements This function should remove the element at the front of the queue and return a pointer to it. } void* q_peek (Queue* q) { 1/1 point Input Specifications A pointer, pointing to a Queue object Expected Return Value A void pointer, pointing to the element that is located at the front of the queue. Extra Requirements This function should successfully return a pointer to the element that is located at the front of the queue } int q_size (Queuet q) { //1 point Input Specifications A pointer, pointing to a Queue object Expected Return value An integer representing the quantified contents within the queue (number of elements) Extra Requirements N/A } bool q_contains (Queuet a, void+ v) { 1/1 point Input Specifications A pointer, pointing to a Queue object and a void pointer, pointing to an element. Expected Return value if the given element is found within the queue, return true. Otherwise return false. Extra Requirements N/A } bool q_destroy (Queue* q) { //1 point Input Specifications A pointer, pointing to a Queue object Expected Return value if the queue had been succesfully deallocated, return true. Otherwise return false. Extra Requirements |This function should deallocate all remaining elements and objects and the queue itself included }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
