1. Implement a 3-levels Priority Circular Queue using arrays.
Let's remember that when arrays are used to implement a priority queue, then a separate queue for each priority number is maintained. Implement each queue as a circular queue. Every individual queue will have its own FRONT and REAR pointers.
Each of the circular queues can hold up to 10 elements.
The Data elements in the queue would be integers numbers.
Provide essential functions to insert and remove elements from the priority queue.
Provide basic functions that to check if the priority queue is Empty or Full.
Provide an auxiliary function that displays the current status of the priority queue.
2. Simulate the traffic in the queue.
Use a random number generator to produce elements that would enter dequeue.
Use a random number between 100-999 to identify the element. For each entry in the priority queue we need two random numbers. First one between 100-999, this is the one that is enqueue. Second, one either 1, 2 or 3, to determine the priority of the element.
Use a Random number between 1 and 3 to denote the priority of the element. Where 1 is the highest priority and 3 is the lowest priority.
Once there are 6 elements in the queue, either 2 or 4 elements exit the queue, after this point for every 3 elements entering the queue 2 or 4 elements exit the queue. (Use a random number to decide if 2 or 4 elements exit the queue)
Display the state of the queue after the exit of the elements from the queue.
3. Save the output simulation behavior of the queue in a text file with the output of the program, showing the initial state and its current state after the exits.
The simulation stops when
There is an Overflow condition. A condition of overflow happened when a Queue, implemented using an array of a fixed sized, attempt to insert a new element when every position in the array is occupied.
There is an Underflow condition. A condition of underflow happens when a Queue, implemented using arrays attempts to remove and element when there are not elements in the queue, in other words when all the position in the array are available
20 elements have exited the queue.
The following is a description of one of these output files.
Initial State of the priority queue with 6 elements.
The current state of the queue with 4 elements after elements A and B exited the queue
3 New elements X, Y, Z, have entered the queue, and elements A, B have exited the queue.
The current state of the queue with 7 elements.
3 New elements X, Y, Z, have entered the queue, and elements A, B have exited the queue.
The current state of the queue with 8 elements.
3 New elements X, Y, Z, have entered the queue, and elements A, B have exited the queue.
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference
and should not be submitted as is. We are not held liable for any misuse of the solutions.
Please see the frequently asked questions page
for further questions and inquiries.
Kindly complete the form.
Please provide a valid email address and we will get back to you within 24 hours.
Payment is through PayPal, Buy me a Coffee
or Cryptocurrency.
We are a nonprofit organization however we need funds to keep this organization operating
and to be able to complete our research and development projects.