Queue Flashcards

1
Q

What is a queue?

A

A data structure that follows the First-In, First-Out (FIFO) principle, where the element that enters first is the one that gets accessed first

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

What are the two main operations of a queue?

A

Enqueue (add), Dequeue (remove)

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

What is a deque (double ended queue)?

A

A queue where elements can be added or removed from both ends of the queue

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

What is a circular queue?

A

A queue where the last position is connected back to the first position, forming a circle

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

What is a priority queue?

A

A queue where each element has a priority, and elements with higher priority are dequeued before elements with lower priority. It can be implemented using heaps

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

What is an affinity queue?

A

A queue where every element has an affinity and is placed with an element having the same affinity; otherwise placed at the rear

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

What is the time complexity of queue operations (enqueue, dequeue, peak, isEmpty)?

A

O(1)

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

Queues can have queue overflow and queue underflow

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