Exam 18: Stacks and Queues

arrow
  • Select Tags
search iconSearch Question
flashcardsStudy Flashcards
  • Select Tags

In the following code, assume the myStack object is a stack that can hold integers, and that value is an int variable. (The lines are numbered for reference purposes.) 1: myStack.push(0); 2: myStack.push(1); 3: myStack.push(2); 4: myStack.pop(value); 5: myStack.pop(value); 6: myStack.pop(value); 7: cout << value << endl; Assume that the pop function, called in lines 4, 5, and 6, stores the number popped from the stack in the value variable. What will the statement in line 7 display?

Free
(Multiple Choice)
4.9/5
(41)
Correct Answer:
Verified

A

This is a container that provides quick access to elements at the front and the back of the list.

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

C

In the following code, assume the myQueue object is a queue that can hold integers, and that value is an int variable. (The lines are numbered for reference purposes.) 1: myQueue.enqueue(0); 2: myQueue.enqueue(1); 3: myQueue.enqueue(2); 4: myQueue.dequeue(value); 5: myQueue.dequeue(value); 6: myQueue.dequeue(value); 7: cout << value << endl; Assume that the dequeue function, called in lines 4, 5, and 6, stores the number removed from the queue in the value variable. What will the statement in line 7 display?

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

C

In the following code, assume the myQueue object is a queue that can hold integers, and that value is an int variable. (The lines are numbered for reference purposes.) 1: myQueue.enqueue(0); 2: myQueue.enqueue(1); 3: myQueue.enqueue(2); 4: myQueue.dequeue(value); 5: myQueue.enqueue(3); 6: myQueue.dequeue(value); 7: cout << value << endl; Assume that the dequeue function, called in lines 4, and 6, stores the number removed from the queue in the value variable. What will the statement in line 7 display?

(Multiple Choice)
5.0/5
(32)

A __________ stack or queue is built around the linked-list.

(Multiple Choice)
4.9/5
(31)

The programmer must declare in advance the size of a dynamic stack or queue.

(True/False)
5.0/5
(40)

In an dequeue operation, the element at the __________ of the queue is removed.

(Multiple Choice)
4.8/5
(39)

The first item placed onto a stack is always the last item removed from the stack.

(True/False)
4.9/5
(44)

Stacks are useful data structures for algorithms that work ___________ with the _________ saved element in the series.

(Multiple Choice)
4.8/5
(42)

The _______ operation allows an item to be stored on a stack.

(Multiple Choice)
4.9/5
(34)

When an element is added to a queue, it is added to the rear. When an element is removed, it is removed from the

(Multiple Choice)
4.9/5
(43)

A dynamic stack has a ___________ size, and is implemented as a(n) ________

(Multiple Choice)
4.9/5
(39)

Stacks and queues can be implemented as arrays or linked lists.

(True/False)
4.9/5
(46)

A dynamic queue can be implemented as a

(Multiple Choice)
4.8/5
(39)

A practical application of the stack data type in a computer system is:

(Multiple Choice)
4.8/5
(40)

A dynamic stack may be implemented as a(n) ___________, and expand or shrink with each push or pop operation.

(Multiple Choice)
4.8/5
(37)

Endeque and deque are the two most common queue operations.

(True/False)
4.9/5
(29)

A __________ is processed in a manner similar to customers standing in a grocery check-out line -- the first customer in line is the first served.

(Multiple Choice)
5.0/5
(41)

A dynamic stack starts as an empty linked list.

(True/False)
4.8/5
(40)

The queue data structure is commonly applied in connection with:

(Multiple Choice)
5.0/5
(43)
Showing 1 - 20 of 46
close modal

Filters

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