Computer Science · Class 12 Optional
Ch 4Queue — Class 12 Computer Science, concept-first.
A queue is a data structure that follows the First-In-First-Out (FIFO) principle. This is the opposite of a stack, which works on Last-In-First-Out (LIFO). In a queue, the element that is added first is the one that gets removed first.
Key concepts
Hover a concept to preview it and jump to its most relevant Q&A.
Queue Underflow Handling
Imagine you're standing at a ticket counter. The queue has a fixed number of people waiting. Now suppose the counter clerk keeps serving customers one by one, but no new customers join the line.
Most relevant Q&A
Chapter contents
The NCERT structure, section by section. Open a section to see its questions, then read the concept-first solution.
Introduction to Queue
A queue is a data structure that follows the First-In-First-Out (FIFO) principle. This is the opposite of a stack, which works on Last-In-First-Out (LIFO).
First In First Out (FIFO)
A queue is built on a simple, real-world rule: the first person to join the line is the first person to be served. This principle is called First In First Out, or FIFO.
Applications of Queue
A queue is a linear data structure that follows the First In, First Out (FIFO) principle — the element that enters first is the one that leaves first.
Operations on Queue
The queue follows the First In, First Out (FIFO) principle. This means the element that has been in the queue the longest is the first one to be removed.
Implementation of Queue using Python
3 QA queue is a linear data structure that follows the First In, First Out (FIFO) principle — the element added first is the one removed first.
+−Activities1 question
+−Activities1 question
+−Think & Reflect1 question
Introduction to Deque
A deque (pronounced “deck”) is a data structure where elements can be added or removed from either end — the front (head) or the rear (tail).
Applications of Deque
2 QA deque (double-ended queue) is a data structure that allows insertion and deletion from both ends — front and rear.
+−Activities1 question
Operations on Deque
A deque (double-ended queue) is a data structure that allows insertion and deletion of elements from both ends — the front and the rear.
Implementation of Deque using Python
A deque (pronounced "deck", short for double-ended queue) is a linear data structure that allows insertion and deletion of elements from both ends — the front and the rear.
Summary
- A queue is an ordered linear data structure that follows the FIFO (First In, First Out) strategy: the element added first is removed first.
Exercises
+−Show 8 questionsHide questions8 questions
- Q1Fill in the blank a) ____________ is a linear list of elements in which insertion and deletion takes place from different ends. b) Operation…Free
- Q2Compare and contrast queue with stack.Free
- Q3How does FIFO describe queue?Free
- Q4Write a menu driven python program using queue, to implement movement of shuttlecock in it's box.Preview
- Q5How is queue data type different from deque data type?Preview
- Q6Show the status of queue after each operation enqueue(34) enqueue(54) dequeue() enqueue(12) dequeue() enqueue(61) peek() dequeue() dequeue()…Preview
- Q7Show the status of deque after each operation peek() insertFront(12) insertRear(67) deletionFront() insertRear(43) deletionRear() deletionFr…Preview
- Q8Write a python program to check whether the given string is palindrome or not, using deque. (Hint : refer to algorithm 4.1)Preview