Stack ADT Flashcards

1
Q

Array based implementation of stack, what are the main methods?

A

Push
Pop
Peek
Size
IsEmpty

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

What are the runtimes of the main methods for an array based stack?

A

Push: theta 1
pop: theta 1
peek: theta 1
size: theta 1
isEmpty: theta 1

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

In a list based implementation of the stack, where is the top?

A

At the front of the list (new elements added to element 0) as we can insert and delete elements in const time from front only

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

What is the runtime for methods in a list based stack implementations?

A

All theta 1 (if implemented correctly)

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