Exam 4: Stacks and Queues

arrow
  • Select Tags
search iconSearch Question
  • Select Tags

____________________ is a technique used to study the performance of a physical system by using a physical, mathematical, or computer model of the system.

Free
(Short Answer)
4.8/5
(36)
Correct Answer:
Verified

Simulation

Complete the following code: /** Returns the next element in the queue. Pre: index references the next element to access. Post: index and count are incremented. @return The element with subscript index */ Public E next() { If (!hasNext()) { ____ } E returnValue = theData[index]; Index = (index + 1) % capacity; Count++; Return returnValue; }

Free
(Multiple Choice)
4.8/5
(25)
Correct Answer:
Verified

A

____ traversal implies that you will follow one path to the end before embarking on a new path.

Free
(Multiple Choice)
4.8/5
(37)
Correct Answer:
Verified

B

A double-linked list requires the same amount of storage as that of a single-linked l ist.

(True/False)
4.9/5
(36)

If a LinkedList is used, insertion at the rear of a queue is a(n) ____________________ operation.

(Short Answer)
5.0/5
(29)

Although reallocating an array is an O(n) operation, it is amortized over n items, so the cost per item is O(n2).

(True/False)
4.9/5
(45)

If an array is used to implement a Queue, insertion at the rear of the array can be done in ____________________ time.

(Short Answer)
4.8/5
(38)

Complete the following code. /** Insert an item at the rear of the queue. Post: item is added to the rear of the queue. @param item The element to add @return true (always successful) */ Public boolean ____(E item) { // Check for empty queue. If (front == null) { Rear = new Node<E>(item); Front = rear; } else { // Allocate a new node at end, store item in it, and // link it to old end of queue. Rear.next = new Node<E>(item); Rear = rear.next; } Size++; Return true; }

(Multiple Choice)
4.9/5
(37)

Because interface Queue extends interface ____, a full implementation of the Queue interface must implement all required methods of that interface.

(Short Answer)
4.9/5
(45)

Removal from the front of a queue is a(n) ____________________ operation.

(Short Answer)
4.7/5
(30)

A(n) _____________________ is a data structure in which objects are inserted at one end and removed from the other.

(Short Answer)
4.8/5
(33)

In computer science, queues are used in operating systems to keep track of tasks waiting for a scarce resource and to ensure that the tasks are carried out in the order that they were generated.

(True/False)
4.9/5
(40)

If the queue is empty, element method throws a(n) ____________________ exception.

(Short Answer)
4.8/5
(42)

Complete the following code: /** Remove the item accessed by the Iter object - not implemented. */ Public void remove() { Throw new ____(); }

(Multiple Choice)
4.7/5
(48)

In a(n) ____________________ array, the elements wrap around so that the first element actually follows the last.

(Short Answer)
4.9/5
(42)

Complete the following code: /** Returns the item at the front of the queue without removing it. @return The item at the front if successful; null if not */ Public E ____() { If (size() == 0) Return null; Else Return theQueue.getFirst(); }

(Multiple Choice)
4.8/5
(33)

____ traversal implies that the nodes visited spread out from the starting point.

(Multiple Choice)
4.9/5
(41)

Through ____________________, the designers of a new system can estimate the expected performance of the system before they actually build it.

(Short Answer)
4.7/5
(35)

When a queue is implemented using a circular array, insertion at the front is ____.

(Multiple Choice)
4.8/5
(31)

When a queue is implemented using a circular array, removal from the rear is ____.

(Multiple Choice)
4.9/5
(32)
Showing 1 - 20 of 28
close modal

Filters

  • Essay(0)
  • Multiple Choice(0)
  • Short Answer(0)
  • True False(0)
  • Matching(0)