Chapter 11 - Queue, Deque, and Priority Queue Implementations

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

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

False

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, no search required

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

O(1)

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

True

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, the available locations are not contiguous.

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

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 )

O(1)

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 )

O(1)

In a doubly linked chain implementation of a queue, what is the performance when the dequeue operation ? d. O(1) e. O(log n) f. O(n) g. O(n2 )

O(1)

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

O(1)

In a two-part circular linked chain implementation of a queue, what is the performance when the dequeue operation ? d. O(1) e. O(log n) f. O(n) g. O(n2 )

O(1)

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

O(n)

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

True

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

True

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

True

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

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

True

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

True, for full queue as well.

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

after the node that freeNode references

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

it is deallocated

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

leave one array location unused

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

linear linked chain

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

maintain a count of queue items

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

tail reference

To efficiently remove a node at the end of a linked chain implementation of a queue requires as a. tail reference b. traversal c. extra reference in the node pointing to the previous node d. none of the above

tail reference

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

the queue's back entry

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

the queue's front entry

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

two more

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

when you frequently add an entry after removing one

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 )

O(1)

In a circular array-based implementation of a queue, explain why checking for frontIndex equal to backIndex + 1 does not work.

Same as empty array condition

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

all the above

In 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 d. nodes all of the above

all the above

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

all the above

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

all the above

In an array-based implementation of a queue, if waitingList is the name of the array, and the index to the last entry in the queue is called backIndex, write a single assignment statement to update backIndex to add an entry to the queue.

backIndex = (backIndex + 1) % waitlingList.Length

In a circular array-based implementation of a queue, if waitingList is the name of the array, and the index to the last entry in the queue is called backIndex, write a single assignment statement to update backIndex to add an entry to the queue.

backIndex = (backIndex + 2) % waitingList.length;

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

both a & b

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

both a & b

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

both the queueNode and freeNode reference the same node

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

circular

6. 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

circular linked chain

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

doubly linked chain

In a circular array-based implementation of a queue, if waitingList is the name of the array, and the index to the last entry in the queue is called frontIndex, write a single assignment statement to update frontIndex to remove an entry to the queue.

frontIndex = (frontIndex - 2) % waitingList.length;

In an array-based implementation of a queue, if waitingList is the name of the array, and the index to the last entry in the queue is called frontIndex, write a single assignment statement to update frontIndex to remove an entry to the queue.

frontIndex = (frontIndex-1)%waitingList.Length

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

one more than the queue's initial capacity


Ensembles d'études connexes

Marketing Test 2 Ch 6, 7, 8, 9, 10, & 11

View Set