Exam 21: Stacks and Queues

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

A stack based on a linked list is based on the following code Class Node{ String element; Node next; Node(String el,Node n){ Element = el; Next = n; } } Node top = null; The code for implementing the String pop()operation is

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

B

A queue based on a linked list uses the following code Class Node{ String element; Node next; Node (String el,Node n){ Element = el; Next = n; } } Node front = null,rear = null; What is the right code for String remove()operation? Such an operation removes and returns an element from the queue.

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

D

In a list implementation of a queue,the end of the list from which elements are removed is called

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

A

The stack pull operation

(Multiple Choice)
4.8/5
(36)

The stack peek operation

(Multiple Choice)
4.7/5
(47)

Consider a class that uses the following variables to implement an array-based stack: String [ ] s = new String[100]; Int top = -1;// Note top == -1 indicates stack is empty A method that implements a String pop()operation can be written as

(Multiple Choice)
4.8/5
(27)

A queue is a container that allows elements to be stored and removed

(Multiple Choice)
4.9/5
(38)

Consider a class that uses the following variables to implement an array-based stack: String [ ] s = new String[100]; Int top = 0; A method that implements the String peek()operation can be written as

(Multiple Choice)
4.9/5
(38)

Consider a class that uses the following variables to implement an array-based stack: String [ ] s = new String[100]; Int top = 0; A method for adding an item x to the stack can be written as

(Multiple Choice)
4.9/5
(35)

In an implementation of a stack based on a singly-linked list,it is most efficient to add a new item so that

(Multiple Choice)
4.9/5
(27)

A queue based on a linked list uses the following code Class Node{ String element; Node next; Node (String el,Node n){ Element = el; Next = n; } } Node front = null,rear = null; What is the right code for the boolean empty()method?

(Multiple Choice)
5.0/5
(28)

In a list implementation of a stack,the end of the list at which elements are added and removed is called

(Multiple Choice)
4.9/5
(38)

Compilers of modern programming languages support method calls and returns with an internal

(Multiple Choice)
4.9/5
(36)

Consider a class that uses the following variables to implement an array-based stack: String [ ] s = new String[100]; Int top = -1;// Note top == -1 indicates stack is empty A method that implements a String peek()operation can be written as

(Multiple Choice)
4.9/5
(30)

In an array-based implementation of a stack,an operation that needs to add a new element to the stack may not be able to complete because the array is full.In this case,the failed operation should

(Multiple Choice)
4.8/5
(38)

The JCF Stack class is used to instantiate a stack: Stack< Integer > intStack = new Stack< Integer >(); The statements Int k = 77; IntStack.push(k*k); Use the primitive type int instead of the wrapper type Integer.These statements

(Multiple Choice)
4.9/5
(34)

A stack is a container that allows elements to be stored and removed

(Multiple Choice)
4.9/5
(39)

A stack based on a linked list is based on the following code Class Node{ String element; Node next; Node(String el,Node n){ Element = el; Next = n; } } Node top = null; The code for implementing the String peek()operation is

(Multiple Choice)
4.8/5
(46)

The operation for removing an item from a queue is called

(Multiple Choice)
4.8/5
(30)

The stack pop operation

(Multiple Choice)
4.9/5
(39)
Showing 1 - 20 of 36
close modal

Filters

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