Data Structure - Quiz 2 Queues

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

When a circular linked chain has one node, the node references itself.

True

When a circular linked chain is used to represent a queue, it is not necessary to maintain a firstNode data field.

True

You can push, pop and get items at either end of the ADT deque.

True

You need two external references for a circular doubly linked chain, one for the firstNode and one for the lastNode.

True

A priority queue cannot have null entries

True

Each node in an ordinary linked chain references only the next node.

True

In a circular array-based implementation of a queue, the available locations are not contiguous.

True

In a circular array-based implementation of a queue, you cannot use only frontIndex to determine when a queue is full.

True

Queues are used in operating systems.

True

The Java Class Library interface Queue method that retrieves and removes the entry at the front of a queue and throws a NoSuchElementException if the queue was empty is a. remove b. poll c. retrieve d. get

A

The ____ ADT organizes its entries according to the order in which they were added. a. queue b. stack c. list d. priority queue

A

The method for adding a new item to the back of a queue is called a. enqueue b. dequeue c. getFront d. none of the above

A

Unlike a stack, a queue does not restrict access to its entries.

False

The Java Class Library interface Queue method that retrieves the entry at the front of a queue but returns null if the queue was empty is a. peek b. empty c. poke d. look

A

The method for retrieving the queue's front entry without altering the queue is called a. getFront b. enqueue c. dequeue d. none of the above

A

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.getBack(); a. Rudy b. Jack c. Larry d. Sam

A

Where does a queue add new items? a. at the back b. at the front c. in the middle d. randomly

A

In a linked chain implementation of a queue, the enqueue operation could potentially be dependent on the other entries and will require a search.

False

The Java Class Library ADT PriorityQueue uses the compareTo method to determine how to order entries.

True

A common alias for the queue method getFront is a. peek b. get c. put d. all of the above

A

After the following statements execute, what item is at the back of the queue? QueueInterface<String> zooDelivery = new LinkedQueue<>(); zooDelivery .enqueue("lion"); zooDelivery .enqueue("tiger"); zooDelivery .enqueue("cheetah"); String next = zooDelivery .dequeue(); next = zooDelivery .dequeue(); zooDelivery .enqueue("jaguar"); a. "jaguar" b. "cheetah" c. "tiger" d. "lion"

A

In a two-part circular linked chain implementation of a queue, what is the performance when the dequeue operation ? a. O(1) b. O(log n) c. O(n) d. O(n^2)

A

In an array-based implementation of a queue, a possible solution to dealing with the full condition is to a. leave one array location unused b. check for frontIndex equal to backIndex c. wait for an arrayFullExcetion to be thrown d. all of the above

A

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

In the linked chain implementation of a queue, the chain's tail last node contains a. the queue's back entry b. the queue's front entry c. both a & b d. none of the above

A

The ADT priority queue organizes objects a. according to priority of the objects b. alphabetically c. from front to back d. from back to front

A

When a counter enumerates simulated time units, it is called a(n) a. time-driven simulation b. clock simulation c. event-driven simulation d. all of the above

A

When a linked chain contain nodes that reference both the next node and the previous node, it is called a(n) a. doubly linked chain b. ordinary chain c. multi-linked chain d. two-way linked chain

A

When would you choose a two-part circular chain over a circular chain? a. when you frequently add an entry after removing one b. when you rarely add entries after removing one c. when you are space constrained d. when you don't want the garbage collector running

A

Where will you find the item added earliest to a queue? a. at the front b. at the back c. in the middle d. randomly

A

The dequeue method a. throws an exception if the queue is empty b. returns the item at the front of the queue c. removes the item at the front of the queue d. all of the above

D

In an array-based implementation of a queue, inserting and deleting entries is accomplished using modulo arithmetic.

True

In an array-based implementation of a queue, keeping the front entry of the queue at queue[0] is inefficient.

True

The Java Class Library interface for Queue has no operation to modify the contents of the front entry.

True

The Queue interface extends the Deque interface.

True

The item most recently added to a queue is at the back of the queue.

True

The null value can be used to signal failure to remove or retrieve an entry from a priority queue when it is empty.

True

The Java Class Library interface Queue method to put an entry on the back of a queue that throws an exception of the method fails is a. add b. offer c. put d. poll

A

The _____ ADT that has operations to add, remove, or retrieve entries at both the front and back of a queue is called a a. deque b. reversible queue c. reversible stack d. all of the above

A

A common alias for the queue method dequeue is a. get b. remove c. delete d. all of the above

B

In a linked chain implementation of a queue, when both the firstNode and lastNode entries are null, the chain is empty.

True

In a circular array-based implementation of a queue, what is the performance when the enqueue operation does not resize the array? a. O(1) b. O(log n) c. O(n) d. O(n2)

A

In a circular array-based implementation of a queue, what is the performance when the enqueue operation if you amortize the cost of resizing the array over all additions to the queue? a. O(1) b. O(log n) c. O(n) d. O(n2)

A

In a ______ the last node references the first node. a. circular linked chain b. array based queue c. array based circular queue d. linked chain

A

In a circular array-based implementation of a queue, what is the performance when the dequeue operation ? a. O(1) b. O(log n) c. O(n) d. O(n2)

A

In a linked chain implementation of a queue, the performance of the enqueue operation is a. O(1) b. O(log n) c. O(n) d. O(n^2)

A

A deque ADT behaves a. like a queue b. like a stack c. both a & b d. none of the above

D

A linked chain whose last node is null is sometimes called a(n) a. linear linked chain b. circular linked chain c. null terminated linked chain d. all of the above

A

After the following statements execute, what item is at the front of the queue? QueueInterface<String> 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

An array whose index of the first location follows the index its last one is call a. circular b. following c. round d. oval

A

How can we tell if a two-part circular linked chain queue is empty? a. both the queueNode and freeNode reference the same node b. the freeNode is one node behind the queueNode c. the freeNode is one node in front of the queueNode d. the empty field is set to true

A

How does a queue organize it items? a. according to the order in which they were added b. by priority c. alphabetically d. randomly

A

In a circular array-based implementation of a queue implementation where one unused location is used to differentiate between the front and back of the queue, the frontIndex is _____ than the backIndex. a. two more b. one more c. one less d. two less

A

In a circular array-based implementation of a queue, the initial size of the array should be a. one more than the queue's initial capacity b. one less than the queue's initial capacity c. two more than the queue's initial capacity d. two less than the queue's initial capacity

A

In a circular linked chain, when a node is removed from the queue a. it is deallocated b. it is moved to a separate list c. it is ignored d. none of the above

A

In a doubly linked chain implementation of a queue, what is the performance when the dequeue operation? a. O(1) b. O(log n) c. O(n) d. O(n^2)

A

In a linked chain implementation of a queue, an external reference to the last node in the chain is called a(n) a. tail reference b. last node c. linked reference d. final node

A

In a linked chain implementation of a queue, the performance of the getFront operation is a. O(1) b. O(log n) c. O(n) d. O(n2)

A

In an array-based implementation of a queue, a possible solution to dealing with the full condition is to a. maintain a count of queue items b. check for frontIndex equal to backIndex c. wait for an arrayFullExcetion to be thrown d. all of the above

A

The Java Class Library interface Queue method that retrieves and removes the entry at the front of a queue and returns null if the queue was empty is a. poll b. remove c. retrieve d. get

A

The Java Class Library interface Queue method that retrieves the entry at the front of a queue but throws a NoSuchElementException if the queue was empty is a. empty b. peek c. poke d. look

A

The Java Class Library interface Queue method to put an entry on the back of a queue that returns false if the method fails is a. offer b. add c. put d. poll

A

The method for removing an item from the front of a queue is called a. dequeue b. enqueue c. getFront d. none of the above

A

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

A

What type of behavior defines a queue? a. first-in first-out b. first-in last-out c. last-in first-out d. none of the above

A

A common alias for the queue method enqueue is a. put b. add c. insert d. all of the above

B

In a circular array-based implementation of a queue, what is the performance when the enqueue operation must resize the array? a. O(n^2) b. O(n) c. O(log n) d. O(1)

B

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(); a. Jack b. Rudy c. Larry d. Sam

B

When adding a node to a two-part circular linked chain implementation of a queue we insert the new node into the chain a. after the node that freeNode references b. before the node that freeNode references c. it has nothing to do with the location of freeNode d. none of the above

B

A two-part circular linked chain implementation of a queue a. is initialized with no available nodes b. keeps nodes that are deallocated for future use c. allocates new nodes on demand when there are no available nodes d. all of the above

C

If we use a chain of linked nodes with only a head reference to implement a queue which statement is true? a. You must traverse the entire chain to access the last node. b. Accessing the last node is very inefficient. c. Both a & b d. None of the above

C

In a linked chain implementation of a queue, when the queue is empty a. the firstNode is null b. the lastNode is null c. both a & b d. none of the above

C

In order to modify the front entry of a queue a. you need a set method defined b. you need to dequeue the front entry, modify the contents, and then use the requeue method to place it back on the front of the queue c. you cannot modify it under any circumstances d. none of the above

C

What item is at the front of the list after these statements are executed? DequeInterface<String> waitingLine = new LinkedDeque<>(); waitingLine.addToBack("Adam"); waitingLine.addToFront("Rudy"); waitingLine.addToBack("Larry"); waitingLine.addToBack("Sam"); waitingLine.addtoFront("Jack"); String name = waitingLine.getFront(); name = getFront(); a. Adam b. Rudy c. Jack d. Sam

C

When adding a node to a two-part circular linked chain implementation of a queue a. first check if a node is already available in the chain b. check to see if the linked chain needs resized c. allocate a new node and assign the reference to freeNode d. all of the above

C

A two-part circular linked chain implementation of a queue a. conceptually has two lists b. uses a freeNode reference for the first available node that follows the queue c. has nodes that form the queue followed by nodes that are available for use in the queue d. all of the above

D

In a two-part circular linked chain implementation of a queue a. queueNode references the front node of the queue b. freeNode references the node that follows the queue c. the queue is empty if queueNode equals freeNode d. all of the above

D

What item is at the front of the list after these statements are executed? DequeInterface<String> waitingLine = new LinkedDeque<>(); waitingLine.addToFront("Jack"); waitingLine.addToBack("Rudy"); waitingLine.addToBack("Larry"); waitingLine.addToFront("Sam"); String name = waitingLine.getFront(); name = getBack(); waitingLine.addtoBack("Adam"); a. Jack b. Rudy c. Adam d. Sam

D

When removing a node from a two-part circular linked chain implementation of a queue a. the entry at the front of the queue is returned b. the node is moved to the part of the chain that is available for the enqueue method c. the queueNode is advanced d. all of the above

D

Which of the following real-world events could be simulated using a queue? a. bank line b. a shared network printer c. restaurant reservation list d. all of the above

D

In a circular array-based implementation of a queue, frontIndex is equal to one less than backIndex when the queue is full.

False

In a circular array-based implementation of a queue, frontIndex is equal to one more than backIndex when the queue is empty.

False

In a linked chain implementation of a queue, the enqueue operation requires a traversal to the end of the chain to insert a new entry onto the queue.

False

The ArrayDeque class implements the Stack interface.

False


Ensembles d'études connexes

Ch 9 Motivating Employees SmartBook

View Set