Stack ADT Flashcards
1
Q
Array based implementation of stack, what are the main methods?
A
Push
Pop
Peek
Size
IsEmpty
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
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
4
Q
What is the runtime for methods in a list based stack implementations?
A
All theta 1 (if implemented correctly)