Stacks Flashcards

1
Q

Hint of Stack

A

Ins and outs

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

is it better than array?

A

It is favorable to store data in a stack than array

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

What does stack use?

A

LIFO- Last in First out

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

Operations-

A
empty()
size() 
top()
push(a)
pop()
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

empty()

A

empty() – Returns whether the stack is empty – Time Complexity: O(1)

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

size()

A

size() – Returns the size of the stack – Time Complexity: O(1)

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

top()

A

top() – Returns the topmost element of the stack – Time Complexity: O(1)

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

pop()

A

pop() – Deletes the topmost element of the stack – Time Complexity: O(1)

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

append()

A

append(a) – Inserts the element ‘a’ at the top of the stack – Time Complexity: O(1)

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

Does stack offer constant time access to the ith item?

A

Stack does not offer constant time access to the ith item.

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

Constant time access-

A

only append() and pop() has the constant time access because it doesn’t shift elements around

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

Is stack linked list?

A

Stack can be implemented as linked list if the items are added and removed from the same side.

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

Stack in Recursive algorithms

A

Append temporary data onto a stack as we recurse, but remove as we bcktrack

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

Can stack help recursive algorithm to iterate?

A

It can be use to implement iteratively.

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