IN C ONLY (follow instruction please) Implement the following functions: Queue * initQueue( ) // Return empty...

80.2K

Verified Solution

Question

Programming

IN C ONLY (follow instruction please)

Implement the following functions:

Queue * initQueue( ) // Return empty queue

// enqueue and dequeue each return an int error code

int enqueue(int, Queue *)

int dequeue(Queue *, int *)

int getQsize(Queue *) // returns # of items inqueue

void freeQueue(Queue *) // Free *all* space

Implement the above using a circular-linked list. Again, alloperations except freeQueue should take O(1) time.

You will need to document each of your functions to inform theuser how to use it and how to interpret its return value. Note thatdequeue places the integer removed from the front of the queue intothe location specified by the reference provided by the user (thesecond parameter). Note also that error conditions can arise forboth enqueue and dequeue.

Also, try implementing the above with a doubly-circular-linkedlist. Does it make things easier or harder?

Answer & Explanation Solved by verified expert
4.4 Ratings (793 Votes)
Tried my best to implement the code as per your requirements Implementing using a Doubly Circular Linked list doesnt make it any easier nor harder In this case no need to to maintain Tail Rear Node in the Queue Struct as Tail Node can be obtained from the previous pointer of the Head Node I implemented the PrintQ method which is a helper function Remove it from the code if you wish I tried my best as far as the Error checking is concerned Please check it and add any error checking code if necessary Thanks include include    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students