Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. What should be the name of the following method? public T whatIsMyname() throws EmptyCollectionException { if(isEmpty()) throw new EmptyCollectionException(Stack); return stack[top-1] } Select one:

1. What should be the name of the following method?

public T whatIsMyname() throws EmptyCollectionException

{

if(isEmpty())

throw new EmptyCollectionException("Stack");

return stack[top-1]

}

Select one:

a. Expand

b. pop

c. Push

d. Peek

2. What is an Abstract Data Type

Select one:

a. Group of values and the operations defined on those values

b. Mathematical model for a data type

c. Subset of those classes that support collection

d. Set of programming constructs and techniques used to implement a collection

3. For Stack data structure, what does the following operation do?

public void doSomething (T element){

If(size() == stack.length)

expandCapacity();

stack[top] = element;

top++;

}

Select one:

a. Pop()

b. isEmpty()

c. Push()

d. Peek()

4. We are using stack to evaluate a postfix expression.

If we feed the following values what final values will be stored at the stack? (hint: Use the logic in the book)

2 4 -1 *

Select one:

a. 2 4 -1 *

b. 6

c. 2 -4

d. -8

5. Stacks operate as _______

Select one.

a. First In, First out

b. arrays

c. Last in, First Out

d. Last out, First In

6. What is missing in the following code?

Public T pop() throws EmptyCollectionException

{

If(isEmpty())

Throw new EmptyCollectionException(Stack);

T result = stack[top];

Stack[top] = null;

Return result;

}

Select one;

a. Top++;

b. Top--;

c. Nothing

d. Expand

7. We are using stack to evaluate a postfix expression.

If we feed the following values what final values will be stored at the stack? ( hint: use the logic in the book)

2 4 -1 * +

Select one;

a. -2

b. 2 -4

c. 2 4 -1 * +

d. -8

Given the following sequence: push(8), pop(), push(9)

Assume we have an initial size of 5 for the array implementation. What would the top pointer show?

Select one;

a. 8

b. 0

c. 7

d. 9

9. Pop operation has O(1) time complexity.

Select one;

a. True

b. False

10. What would the following program print?

X. push(new Integer(4));

X. push(new Integer(3));

Integer Y = X.pop();

X.push(new Integer(7));

X.push(new Integer(2));

X.push(new Integer(5));

X.push(new Integer(9));

System.out.print(Y);

Select one:

a. 2

b. 3

c. 7

d. 9

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_2

Step: 3

blur-text-image_3

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

Database Programming With Visual Basic .NET

Authors: Carsten Thomsen

2nd Edition

1590590325, 978-1590590324

More Books

Students also viewed these Databases questions

Question

3. Review the evidence. Do you believe the testimony presented?

Answered: 1 week ago

Question

5. Our efficiency focus eliminates free time for fresh thinking.

Answered: 1 week ago