Queues Flashcards

1
Q

True or False: You can only pop from a queue in Python

A

False - all queues are double ended queues (deque) by default

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

What is the package we have to import to initialize a deque in Python?

A

from collections import deque

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

How would we add a value to a deque?

A

queue.append(1)

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

How would we pop from the left side of a queue in Python?

A

queue.popleft()

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

How would we add a value to the left side of a deque in Python?

A

queue.appendleft(1)

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

How can we get the last value from a deque in Python?

A

queue.pop()

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