Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

JAVA (Data structure) Stack and queque 7) What are the values for indexOfFront, indexOfRear and size of queue after the last operation is executed for

"JAVA (Data structure) Stack and queque

7) What are the values for indexOfFront, indexOfRear and size of queue after the last operation is executed for a circular queue.

(you must provide three values)

ArrayQueue myQ = new ArrayQueue( 5);

array size is 5. (there are 5 slots in the array)

operation indexOfFront indexOfRear size of queue

myQ.enqueue(one);

myQ.enqueue(two);

myQ.enqueue(three);

myQ.dequeue( );

myQ.dequeue( ); myQ.dequeue( );

myQ.enqueue(four);

myQ.enqueue(five);

myQ.enqueue(six);

myQ.enqueue(seven);

myQ.dequeue( );

myQ.enqueue(eight);

myQ.dequeue( );

8) State why implementing a queue using a "circular array" is more efficient that having the index of the front fixed at 0.

9) What is the principle difference in behavior between a stack and a queue?

a stack is used to reverse order of the data whereas a queue preserves order
access to the data in a stack can be done in any order, but access to the data in a queue is from the front of the queue only
there is no difference in the access to the data in a stack vs a queue
a stack is used to preserve the order of the data and a queue is used to reverse the order of the data

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

Database Principles Programming And Performance

Authors: Patrick O'Neil

1st Edition

1558603921, 978-1558603929

More Books

Students also viewed these Databases questions

Question

Explain all drawbacks of application procedure.

Answered: 1 week ago