CS 2114 Reading Quiz 7
After the following statements execute, what item is at the front of the queue? QueueInterface zooDelivery = new LinkedQueue(); zooDelivery .enqueue("lion"); zooDelivery .enqueue("tiger"); zooDelivery .enqueue("cheetah"); String next = zooDelivery .dequeue(); next = zooDelivery .dequeue(); zooDelivery .enqueue("jaguar"); a) "cheetah" b) "jaguar' c) "tiger" d) "lion"
a) "cheetah"
Imagine you have an empty queue of strings named queue. What is the contents of the queue from front to rear, (listed left to right below), after the following operations have executed. queue.enqueue("K"); queue.enqueue("P"); queue.dequeue(); queue.enqueue("G"); String str = queue.getFront(); queue.enqueue("R"); queue.dequeue(); queue.enqueue("V"); queue.enqueue(str); a) GRVP b) GVGK c) KPGR d) KGRVP e) PGRVP
a) GRVP
In a circular array-based implementation of a queue, what is the performance when the dequeue operation ? a) O(1) b) O(logn) c) O(n) d) O(n^2)
a) O(1)
In a linked chain implementation of a queue, the performance of the enqueue operation is: a) O(1) b) O(logn) c) O(n) d) O(n^2)
a) O(1)
What item is at the front of the list after these statements are executed? DequeInterface waitingLine = new LinkedDeque(); waitingLine.addToFront("Jack"); waitingLine.addToBack("Rudy"); waitingLine.addToBack("Larry"); waitingLine.addToFront("Sam"); String name = waitingLine.getFront(); name = waitingLine.getBack(); a) Sam b) Adam c) Rudy d) Jack
a) Sam
In the linked chain implementation of a queue, the chain's first node contains: a) the queue's front entry b) the queue's back entry c) both a & b d) none of the above
a) the queue's front entry
What item is at the front of the list after these statements are executed? DequeInterface waitingLine = new LinkedDeque(); waitingLine.addToFront("Jack"); waitingLine.addToFront("Rudy"); waitingLine.addToBack("Larry"); waitingLine.addToBack("Sam"); String name = waitingLine.getBack(); a) Jack b) Rudy c) Larry d) Sam
b) Rudy
What item is at the front of the list after these statements are executed? DequeInterface waitingLine = new LinkedDeque(); waitingLine.addToFront("Jack"); waitingLine.addToFront("Rudy"); waitingLine.addToBack("Larry"); waitingLine.addToBack("Sam"); String name = waitingLine.getFront(); a) Jack b) Rudy c) Larry d) Sam
b) Rudy
What type of behavior defines a queue? a) first-in last-out b) first-in first-out c) last-in first-out d) none of the above
b) first-in first-out
Where does a queue add new items? a) randomly b) in the middle c) at the back d) at the front
c) at the back
When a linked chain contains nodes that reference both the next node and the previous node, it is called a(n): a) multi-linked chain b) two-way linked chain c) doubly linked chain d) ordinary chain
c) doubly linked chain
To efficiently remove a node at the end of a linked chain implementation of a queue requires a: a) tail reference b) traversal c) extra reference in the node pointing to the previous node d) none of the above
c) extra reference in the node pointing to the previous node
In a circular array-based implementation of a queue, the initial size of the array should be: a) two more than the queue's initial capacity b) two less than the queue's initial capacity c) one more than the queue's initial capacity d) one less than the queue's initial capacity
c) one more than the queue's initial capacity
Where will you find the item added earliest to a queue? a) randomly b) in the middle c) at the back d) at the front
d) at the front