Question: A Queue of chars ( characters )Data structure is given below as shown in the diagram. In this Circular Queue implementation is done in such

A Queue of chars ( characters )Data structure is given below as shown in the diagram.

In this Circular Queue implementation is done in such a way that the rear circles to the front of the array if there are empty slots in the front and a reserved spot is used as the front before the first element to differentiate between the front and the rear.

Front of the Queue is index 2 and rear of the Queue is index 13. Following are the alphabets occupying the following indices.

H - 3; A - 4; P - 5; Y - 6; M - 7; I - 8; D - 9; T - 10; E -11; R - 12 and M - 13.

Four new entries decide to join the Queue.

E

X

A

M

E comes in first, X next, A next and M next.

1) Where will these values go be placed in the Queue? Just state the alphabet and the index of the array where each of these characters will be placed in the Queue.

( So for example if E goes into index n ( a number) Just say E - index n.)

Assume that no alphabet leaves the Queue during this time and only addition takes place. Also assume that in this approach rear can circle around to the front.

2) After these alphabets are added in the Queue what index will be the front and rear of the Queue pointing to?

3) Now imagine one alphabet is Dequeued ( or removed from the Queue) before adding E X A and M. Where will be these new values added and state which index does the front and rear of the same Queue would be pointing to?

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!