Question: 2. Consider an initially empty queue Q stored in array 0(0..5]. Assume that FRONT and REAR pointers are all initialized to -1. The question marks

 2. Consider an initially empty queue Q stored in array 0(0..5].

2. Consider an initially empty queue Q stored in array 0(0..5]. Assume that FRONT and REAR pointers are all initialized to -1. The question marks in the figure indicate that the contents of the array are unknowns. (a) Show the contents of the array after performing all of the following operations: ENQUEUE(CQ, 4), ENQUEUE CQ.1), ENQUEUE , 3), DEQUEUECO), ENQUEUE Q, 8), and DEQUEUEO). Here, ENQUEUE refers to inserting an element into the queue, and DEQUEUE refers to removing an element from the queue. Indicate where the FRONT and REAR pointers are. (b) Now, assume that the array is circular, i.e., the array wraps around. Also, assume that we double the queue size (using realloc) when the queue is full. Show the contents of the array (with resizing if necessary) when another four operations are then performed: ENQUEUE(Q, 14), ENQUEUE Q,11), ENQUEUE Q, 13), ENQUEUE CO, 18). Indicate where the FRONT and REAR pointers are

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!