Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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.

J

O

H

N

J comes in first, O next, H next and N next.

1) (5 pts.) 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 J goes into index n ( a number) Just say J - 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) (5 pts.) After these alphabets are added in the Queue what index will be the front and rear of the Queue pointing to?

3) (5 pts.) Now imagine one alphabet is Dequeued ( or removed from the Queue) before adding J O H and N. 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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Students also viewed these Databases questions