Queue Flashcards
What is a queue?
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
What are the two main operations of a queue?
Enqueue (add), Dequeue (remove)
What is a deque (double ended queue)?
A queue where elements can be added or removed from both ends of the queue
What is a circular queue?
A queue where the last position is connected back to the first position, forming a circle
What is a priority queue?
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
What is an affinity queue?
A queue where every element has an affinity and is placed with an element having the same affinity; otherwise placed at the rear
What is the time complexity of queue operations (enqueue, dequeue, peak, isEmpty)?
O(1)
Queues can have queue overflow and queue underflow