Data Strucuture Question related to Priority Queue

aashishdas
CS2413Lab3.pdf

Texas Tech University Whitacre College of Engineering

1 of 2

CS 2413 – Data Structures Fall 2019

LAB 3 Sep 25, 2019

Acknowledge your collaborators or source of solutions, if any. Submission through Blackboard is required. This exercise is for getting familiar with Queue. Please be advised that test cases only need to provide the Correct Input and the Correct Output, and screenshots are not required in these cases. Also, the 3 Text Files from Part 3 can be used to illustrate the testing of the program as a whole. Do all of the following. A subset of your solutions will be graded.

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 de queue. Use a random number between 100-999 to identify 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.

Texas Tech University Whitacre College of Engineering

2 of 2

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 • There is an Underflow condition • 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. • The current state of the queue with 9 elements.

Your compliance with the “PROGRAMMING STYLE GUIDELINE” mentioned in the LAB will affect your actual grade. All assignments will be checked for academic misconduct (cheating, plagiarism, collusion, falsifying academic records, misrepresenting facts, violations of published professional ethics/standards, and any act or attempted act designed to give unfair academic advantage to oneself or another student) defined by “OP 34.12: Grading Procedures, Including Academic Integrity” of TTU. Special software will be used to uncover for such attempts.