Stacks Flashcards

1
Q

What is an ADT ( Abstarct Data Type )

A

ADT is a formal description of the data structure ( what it does and etc).
ADT is not the programming language or the code of the data structure

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

What is a linear structure ?

A

Non-indexed container object that can grow and shink one element at a time.

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

In each order are elements acessed in a stack ?

A

LIFO: Last in, First out:

i.e. pile of books

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

How does a stack solves the maze problem

A

By pushing all possible next steps into the stack, popping and moving to them, when arriving to next one seeing possible next ones.

Problem : we can see the maze

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

What is the difference between a stack and a queue.

A

Stack pop and push from the top

queue, enqueue from the end, dequeue from the front

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

Does it make a difference to have the top of the stack at position 0 or n? If yes, which one is better, and how does the Big O notation change from it

A

Yes. It is better to have the top at position n so when you push and append you get O(1). instead of O(n).

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

What is one additional benefit from encapsulation?

A

Being able to change the location of the top without having to change the whole implementation.

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

What is a Stackframe?

A

a stack frame is a memory management technique used in some programming languages for generating and eliminating temporary variables. In other words, it can be considered the collection of all information on the stack pertaining to a subprogram call.

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

What are operands and operators

A

operands => numbers

operators => multiplication etc

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

What is an infix notation

A

Operator in the middle of operands

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

Reverse Polish Notation

A

Postfix ( the operator comes after the operands )

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

Polish Notation

A

Infix ( the operator comes before the operands)

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

What is the Big O notation of reversing a list? If we use a stack to do so what would be the Big O?

A

O(n), Stack O(1)

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