Stacks and Queues Flashcards

1
Q

What is used to make a stack?

A

Linked Lists

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

What is the runtime of push?

A

O(1)

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

Which structure if LIFO and define LIFO.

A

Stack is LIFO; last in first out. Whatever the last element added in to the array will be the first element removed.

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

What is the runtime of pop?

A

O(1)

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

What can stacks not do?

A

No searching or sorting. Can only use the push and pop functions.

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

Which structure is FIFO and define FIFO.

A

Queue is FIFO; first in first out. Whatever is the first element in the array is the first element to be removed.

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

What is the runtime of enqueue?

A

O(1)

Adds elements to the back

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

What is the runtime of dequeue?

A

O(1)

Removes elements from the front

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

What can queue not do?

A

No searching or sorting. Can only enqueue and dequeue (add and remove).

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

How do we make the functions in queue O(1)?

A

By keeping track of the tail (end) node.

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