How to answer the following questions?

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

How to answer the following questions?

Which of the following statements is a legal declaration/instantiation of a Stack object?

A. StackInterface<String> stack;
B. StackInterface<String> stack = new ArrayBoundedStack<String>(3);
C. StackInterface<String> stack = new StackInterface<String>;

Evaluate the following postfix expression:  6  4 +  3  10  * 2 2 2 -  +  * + What is the highest number of elements on our stack at any one time

A. 2  B. 3 C. 4 D. 5

While evaluating the following postfix expression:  6  4 +  3  10  * +  2 2 -  +  how many times is the push operation called? A. 1  B. 6  C. 9  D. 11  E. 18

How did you decide to handle the possibility of stack underflow?

A. Assume as a precondition that it will not occur.
B. Throw a StackUnderflowException if it occurs.
C. Provide an isEmpty operation so a client can prevent underflow.
Ignore it.
D. Throw a StackUnderflowException if it occurs, and provide an isEmpty operation so a client can prevent underflow.
 

Here is a, possibly flawed, approach for using a traversal to print the contents of the linked list of strings accessed through letters. Indicate the description that best matches the code.

LLNode<String> currNode = letters;

while (currNode != null) {

System.out.println(currNode.getInfo());

if (currNode.getLink() != null)

currNode = currNode.getLink();

 else

currNode = null;

}

A. very good B. correct but inefficient C. correct but too complex D. will bomb if list is empty  E. will bomb if list is not empty
 

What is the result of evaluating the following postfix expression?

  6  4 + * 3  10 +

A. 0 B. 3  C. too many operands D. too few operands

stack implementations throw an exception if a pop is attempted on an empty stack. A valid alternate approach to handling this situation is to:

A. ignore it B. state as a precondition that pop will not be attempted on an empty stack.
C. have the pop operation return a boolean indicating success. 
D state as a precondition that pop will not be attempted on an empty stack, and have the pop operation return a boolean indicating success. 
E. state as a precondition that pop will not be attempted on an empty stack, or have the pop operation return a boolean indicating success.

which of these statements is the best representation of the current status of a Stack ADT in the Java Standard Library?

A. There is no support for stacks in the library.  B. The library provides a Stack class. 

C. The library does not provide a Stack class, but does provide other classes that can be used for the same functionality.

D. The library provides a DeQue class that supports stack operations.
E. The library provides a legacy Stack class, but it is better to use the DeQue class for stacks.
 
 the ArrayBoundedStack the topIndex variable holds the index of the elements array where the current top of stack is stored. Which of the following code sequences could be used to correctly remove the top element of the stack, assuming that pop is called on a non-empty stack?
A. topIndex--;  B. elements[topIndex] = null; C. elements[topIndex] = null; topIndex--;
D. topIndex--; elements[topIndex]= = null;
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps

Blurred answer
Knowledge Booster
Stack
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education