Can someone please double check to make sure I have these right. Here are the instructions...

Assume that q is a queue implemented as described using circular array with queueElement = char and capacity 5, and then ch is of type char. Show the values of myFront and myBack and the contents of myArray for the Queue object q after the program segment has been executed, also indicate any errors that occur...

1.

q.enqueue('X');

q.enqueue('Y');

q.enqueue('Z');

while (!q.empty())

{

ch = q.front();

q.dequeue();

}

For this one I put myFront = 3 and myBack = 4 but dont know what yo do for myArray

3.

ch = 'A';

for (int i = 1; i <=4; i++)

{

q.enqueue(ch);

ch++;

q.enqueue(ch);

ch = q.front();

q.dequeue();

}

For this one I put myFront = 1, myBack = 4 and also not sure what to pout for myArray...can someone please take a look and offer assistance. I need this to be looked at by 5. I apologize for the short notice.

Recommended Answers

All 2 Replies

Please use code tags. It significantly improves readability (and hence likelihood of a reply :) )

Apologies

1.

q.enqueue('X');

q.enqueue('Y');

q.enqueue('Z');

while (!q.empty())

{

ch = q.front();

q.dequeue();

}



For this one I put myFront = 3 and myBack = 4 but dont know what yo do for myArray





3.

ch = 'A';

for (int i = 1; i <=4; i++)

{

q.enqueue(ch);

ch++;

q.enqueue(ch);

ch = q.front();

q.dequeue();

}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.