Stack ADT Flashcards

1
Q

What is a collection?

A

A collection is a group of items that we wish to treat as a conceptual unit.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is a stack?

A

A collection whose elements are added and removed from one end, called the top of the stack.

A stack is a LIFO data structure (last in first out).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is an ADT?

A

An abstract data type is a collection of data together with the operations on that data.

It specifies WHAT the operations do, NOT how they do it.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is abstraction?

A

It separates the purpose of an entity from its implementation.

Eg. We don’t need to know how a car works in order to drive one.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is a Java interface?

What must it be declared as? What must its constants be declared as?

A

A list of abstract methods (signatures) and constants.

Must be public, constants must be declared as static final.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What does mean in the interface definition?

A

It’s the generic type. The actual type is known only when an app. program creates an object of that class.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Describe an algorithm that evaluates postfix expressions.

A

Scan from left to right, determining if the next token is an operator or operand.

If it is an operand, push it on the stack.

If it is an operator, pop the stack twice to get the two operands, perform the operation, and push the result back onto the stack..

How well did you know this?
1
Not at all
2
3
4
5
Perfectly