Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Answer The Following Multiple Choice Questions And Choose the Correct Answer (1-4). The operation that adds a new item to a stack is... Question 1

Answer The Following Multiple Choice Questions And Choose the Correct Answer (1-4).

The operation that adds a new item to a stack is...

Question 1 options:

1.

push

2.

insert

3.

pop

4.

remote

Question 2:

A stack is one kind of ____ data structure.

Question 2 options:

1.

FIFO

2.

LIFO

3.

FINO

4.

all of the above

Question 3:

When you run the following code:

stack s; // the stack is empty when first created s.push(42); s.push(73); assert(!s.empty()); // Assert A s.pop(); s.push(23); assert(!s.empty()); // Assert B s.pop(); assert(!s.empty()); // Assert C

Question 3 options:

1.

assert A will fail

2.

assert B will fail

3.

assert C will fail

4.

it will finish without any of the asserts failing

Question 4:

When you run the following code:

stack s; // the stack is empty when first created s.push(0); s.push(1); s.push(2); assert(s.size() == 3); // Assert A s.pop(); assert(!s.empty()); // Assert B int n = s.top(); for (int i = 0; i < n; i++) { s.pop(); } assert(s.top() == 1); // Assert C

Question 4 options:

1.

assert A will fail

2.

assert B will fail

3.

assert C will fail

4.

it will finish without any of the asserts failing

Question 5:

The stack::top method returns by reference. One reason for this is that...

Question 5 options:

1.

it wouldn't be possible to return the item by value

2.

it avoids making a copy of the item being returned

3.

it means the item will continue to exist if the stack is destroyed

4.

the caller would otherwise have to free the item manually

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Learning PostgreSQL

Authors: Salahaldin Juba, Achim Vannahme, Andrey Volkov

1st Edition

178398919X, 9781783989195

More Books

Students also viewed these Databases questions