logo

Crowdly

Given the following struct definitions of a linked-list based queue:   ...

✅ The verified answer to this question is available below. Our community-reviewed solutions help you understand the material better.

Given the following struct definitions of a linked-list based queue:

 

struct QueueNode

{

struct QueueNode

*next;

unsigned int

value;

};

struct Queue

{

struct QueueNode

*front;

struct QueueNode

*rear;

};

// <![CDATA[

hljs.highlightAll();

// ]]>

 

Task 1: Write an insert function to insert an item at the end of the queue. The function prototype has been provided for you below.

void insert(struct Queue* queue, unsigned int value);

 

Task 2: Write a serve function to serve (remove) an item (from the front) of the queue. The function prototype has been provided for you below.

int serve(struct Queue* queue);

 

Task 3: In the main function, write code that does the following:

  • Reads in a single string of letters and numbers (you can assume that the only letter will be an 's' character)
  • For each single

    character in the string:

    • If it is a numerical character, convert that character to an integer and insert it into the queue
    • If it is an 's', serve the next item in the queue and print that integer to the console, followed by a single space character

 

 

Notes:

  • You may also use whatever editor/test environment you like to write your solution.
  • Your code MUST be submitted as a .txt file below BEFORE the end of the test
  • Your code will be run against test cases and manually reviewed
  • You may wish to define additional functions as needed
  • You should use good programming practices

Your code MUST be submitted as a .txt file BEFORE the end of the test (copy and paste into a .txt file).

More questions like this

Want instant access to all verified answers on learning.monash.edu?

Get Unlimited Answers To Exam Questions - Install Crowdly Extension Now!