Question 110 pts What are the contents of the queue bankLine

Question 110 pts

What are the contents of the queue bankLine after the following statements execute? The front of the queue in the answers is the left-most value

QueueInterface<String> bankLine = newLinkedQueue<>();
bankLine .enqueue(“John”);
bankLine .enqueue(“Matthew”);
String next = bankLine .dequeue();
bankLine .enqueue(“Drew”);
bankLine .enqueue(“Heather”);
bankLine .enqueue(“David”);
next = bankLine .dequeue();

Flag this Question

Question 210 pts

What are the contents of the deque waitingLine after the following statements execute? The front of the queue in the answers is the left-most value

DequeInterface<String> waitingLine = new LinkedDeque<>();
waitingLine.addToFront(“Jack”);
waitingLine.addToFront(“Rudy”);
waitingLine.addToBack(“Larry”);
waitingLine.addToBack(“Sam”);
String name = waitingLine.removeFront();

Flag this Question

Question 310 pts

How does a queue organize its items?

Flag this Question

Question 410 pts

The ADT priority queue organizes objects

Flag this Question

Question 510 pts

What item is at the front of the list after these statements are executed?

DequeInterface<String> waitingLine = new LinkedDeque<>();
waitingLine.addToFront(“Jack”);
waitingLine.addToFront(“Rudy”);
waitingLine.addToBack(“Larry”);
waitingLine.addToBack(“Sam”);
String name = waitingLine.getFront();

Flag this Question

Question 610 pts

If we use a chain of linked nodes with only a head reference to implement a queue, which statement is true?

Flag this Question

Question 710 pts

In the linked chain implementation of a queue, the chain’s first node contains

Flag this Question

Question 810 pts

In a linked chain implementation of a queue, the performance of the enqueue operation is

Flag this Question

Question 910 pts

In a linked chain implementation of a queue, the performance of the getFront operation is

Flag this Question

Question 1010 pts

In a circular array-based implementation of a queue, what is the performance when the enqueue operation must resize the array?

John, Drew, Heather

Solution

Answer:

b) Drew Heather David

Imagine you are a cashier .There is a line up of customers ,which customer will you serve first? The one who is in front of the line? Or the one who is in back of the line? Obiviously the front customers. So, the Queue structure is similar to the customer line .Enqueue means a new customer came and stand in back of the line and dequeue means you served the first customer and the first customer left.

enqueue(\"John\") : - Means john entered the line

Then it said : enqueue(Mathew)

So John, and Mathew is in the line.

Then the code executed dequeue() . Since John is in front (as he came first), so you served John and he left

So it is just mathew.

The enqueue(drew)

So now, the queue has Mathew, Drew

Now , Enqueue(Heather) means now the queue has mathew, drew, heather

Then enqueue(david)

so mathew, drew, heather, david is in the queue

Then it called dequeue()

Means mathew left, because he was first in line

So the queue in the end will contain drew, heather, and david.

Answer:

Here front means left value

addtofront(jack) ----> jack

addtofront(rudy) -----> rudy, jack

addtoback(larry) ----> rudy, jack, larry

addtoback(sam) -------> rudy, jack, larry, sam

removefront ----> jack, larry, sam

Question 110 pts What are the contents of the queue bankLine after the following statements execute? The front of the queue in the answers is the left-most valu
Question 110 pts What are the contents of the queue bankLine after the following statements execute? The front of the queue in the answers is the left-most valu
Question 110 pts What are the contents of the queue bankLine after the following statements execute? The front of the queue in the answers is the left-most valu

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site