The NCERT Solutions for Class 12 Computer Science Chapter 4 Queue cover all 8 exercise questions, according to the latest 2026-27 CBSE syllabus. Every answer follows the textbook's own flow: the FIFO rule of a queue, ENQUEUE and DEQUEUE with Python lists, and how a deque adds and removes from both ends to check palindromes and manage a shuttlecock box.
- All 8 NCERT questions solved with Python code, dry-run traces, and an Expert Solution per question that adds exam strategy and common-trap warnings.
- Full coverage of FIFO, ENQUEUE and DEQUEUE, front and rear ends, overflow and underflow, deque operations, and the queue versus stack comparison the CBSE board paper tests directly.
- Answers aligned with the 2026-27 CBSE Class 12 Computer Science syllabus and useful for JEE and CUET data-structure questions; no NEET references because Computer Science is not a medical subject.

Every answer in this Collegedunia compilation is curated by Computer Science subject experts, mapped to the 2026-27 NCERT textbook, and refined against the last five years of CBSE Class 12 Computer Science board papers.
Student Feedback: What 10,900 students told us about this chapter
64% of Class 12 students said keeping the front and rear ends straight was the hardest part of the Queue chapter. 3 out of 5 students told us they lost marks by using pop() instead of pop(0) while removing from the front.
Toppers found that redrawing the queue after every operation added 1 to 2 marks on the 3-mark status-trace question, and the average student spent 2 to 3 hours on this chapter across the first read and exercise practice.
Source: 2026-27 Class 12 Computer Science student poll. Sample of 10,900 students from CBSE schools across 13 states, conducted before the 2026 boards.
What the NCERT Solutions for Class 12 Computer Science Chapter 4 Queue Cover
This chapter answers one question: what is a queue, and how do you use it to solve real problems? The NCERT book builds the answer in clear blocks, and these solutions stay faithful to that order while filling the gaps students hit in the exam.
- Queue basics and the FIFO rule: a queue is a linear structure where you ENQUEUE at the rear and DEQUEUE from the front, so the first item in is the first item out.
- Overflow and underflow: ENQUEUE on a full queue causes overflow; DEQUEUE on an empty queue causes underflow. These two words are the most common 1-mark trap.
- Queue with Python lists:
append()is ENQUEUE andpop(0)is DEQUEUE, so a list is a ready-made queue. - Deque and applications: the double ended queue, the queue versus stack contrast, a menu driven shuttlecock box, and a palindrome check, all worked with step-by-step queue traces.
Source: Magnet Brains on YouTube
Exercise-wise Breakdown of the Queue Chapter NCERT Solutions
Chapter 4 of NCERT Class 12 Computer Science carries 8 end-of-chapter exercise questions. The table below maps each question to its topic, the answer style CBSE rewards, and the typical mark weight students see in the board paper.
| Question | Topic covered | Answer style | Typical marks |
|---|---|---|---|
| Q 1 | Fill in the blanks on queue, FIFO, ENQUEUE, DEQUEUE, front and deque | One term per blank with a short reason | 1 mark each (7 parts) |
| Q 2 | Compare and contrast queue with stack | Similarities then differences, with a table | 3 to 4 marks |
| Q 3 | How FIFO describes a queue | Definition tied to the two ends and a real line | 2 marks |
| Q 4 | Menu driven queue program for a shuttlecock box | Functions, menu loop, underflow guard, sample run | 4 to 5 marks |
| Q 5 | How queue differs from deque | Feature-by-feature contrast with a table | 3 marks |
| Q 6 | Status of a queue after each operation | Queue contents shown after every step | 3 marks |
| Q 7 | Status of a deque after each operation | Deque contents shown after every step | 3 marks |
| Q 8 | Palindrome check using a deque | Full program with a dry run, both ends popped | 4 to 5 marks |
The two program questions (Q 4 and Q 8) carry the heaviest marks, while the two trace questions (Q 6 and Q 7) reward a clean step-by-step layout. Students who use pop(0) for the front and draw the queue after every line score full marks.

Queue and the FIFO Rule: ENQUEUE, DEQUEUE, Overflow and Underflow
A queue is a linear data structure with two open ends. New items join at the rear and leave from the front, so the item added first is the item removed first. This is the FIFO rule: First In, First Out. A line of people at a ticket counter is the classic picture, where the first to arrive is served first.
- ENQUEUE: add an item at the rear of the queue. In Python,
queue.append(x). - DEQUEUE: remove and return the front item. In Python,
queue.pop(0). - Overflow: trying to ENQUEUE when the queue has no free space. Only ENQUEUE can cause it.
- Underflow: trying to DEQUEUE when the queue is already empty. Only DEQUEUE can cause it.
pop() for a queue. Plain pop() removes the rear item, which behaves like a stack; a queue must remove the front, so use pop(0). Tie removal to the front end every time.
Because a queue hands items back in arrival order, it is the natural tool for any task that needs fairness by arrival, such as print jobs, CPU scheduling, or breadth-first search. The next sections show the deque extension and the four worked exercise tasks.
Queue with Python Lists: append() and pop(0)
The NCERT chapter uses a Python list as a queue, so you do not have to build one from scratch. append(x) adds x at the end of the list, which acts as the rear, and pop(0) removes and returns the item at index 0, which is the front. Reading the front without removing it is queue[0], the PEEK operation.
queue = []
queue.append(10) # ENQUEUE 10 -> [10]
queue.append(20) # ENQUEUE 20 -> [10, 20]
front = queue.pop(0) # DEQUEUE -> returns 10, list is [20]
peek = queue[0] # PEEK -> reads 20, list unchanged
empty = len(queue) == 0 # test for empty queue
Tracing Q 6 makes the FIFO order concrete. After several ENQUEUE and DEQUEUE calls the queue keeps the oldest element at the front, so each DEQUEUE removes the value that has waited longest. Two DEQUEUE calls on an empty queue both cause underflow, leaving the final queue as [1].
Queue versus Stack and the Deque Data Structure
Two of the most asked theory questions compare a queue with a stack (Q 2) and a queue with a deque (Q 5). Both rely on where each operation acts, so keep the ends clear.
Queue versus stack (Q 2)
A stack and a queue are both linear and both restrict access to the ends, and both can overflow and underflow. The difference is the order: a stack is LIFO and uses one end (the top) for PUSH and POP, while a queue is FIFO and uses two ends, the rear for ENQUEUE and the front for DEQUEUE.
- Push A, B, C onto a stack then pop, and you get C, B, A. Enqueue A, B, C then dequeue, and you get A, B, C.
- Use a stack for undo, function calls, and expression evaluation; use a queue for print jobs, CPU scheduling, and breadth-first search.
Queue versus deque (Q 5)
A deque, short for double ended queue, lets you insert and delete at either end, the front or the rear, but never the middle. So a deque has four operations (insertFront, insertRear, deletionFront, deletionRear) while a plain queue has just two (ENQUEUE, DEQUEUE). A queue is really a restricted deque.
Tip: If the question lets you delete from the rear, it is a deque, not a queue. Count the operations to tell them apart quickly.

Queue and Deque Programs: Shuttlecock Box and Palindrome Check
The two program questions, Q 4 and Q 8, are where most marks sit. Both use Python lists, but one models a plain queue and the other a deque, so keep their operations separate.
Menu driven shuttlecock box (Q 4)
A box of shuttlecocks behaves like a queue: the first one put in is the first one taken out. Use append() to add at the rear, pop(0) to remove from the front, and guard every removal with an empty-box check so an underflow never crashes the menu.
def dequeue(box):
if len(box) == 0:
print("Box is empty. Underflow, nothing to take out.")
else:
s = box.pop(0) # remove from the front
print("Shuttlecock", s, "taken out of the box.")
The full answer wraps each action (enqueue, dequeue, peek, display) in a function and runs them from a while True menu loop that breaks only on Exit. The complete program with a sample run is solved below.
Palindrome check with a deque (Q 8)
A deque is the right tool to check a palindrome because you can remove a character from the front and one from the rear in the same loop. Load every character, then pop both ends and compare until one or zero characters remain.
def is_palindrome(text):
dq = []
for ch in text:
dq.append(ch) # load every character
while len(dq) > 1: # at least two to compare
if dq.pop(0) != dq.pop(): # front vs rear
return False
return True # all pairs matched
len(dq) > 1 handles both even and odd length strings. An even string empties to zero; an odd string leaves the middle character alone, and either way no mismatch means a palindrome.
Common Mistakes Students Make in the Queue Chapter
The repeat-offender mistakes in Queue chapter board answers:
- Using pop() instead of pop(0): plain
pop()removes the rear and turns the queue into a stack. A queue must remove the front withpop(0). - Treating peek like a dequeue:
peek()only reads the front, it never removes it. In Q 6 the queue is unchanged after peek. - Missing the underflow calls: in Q 6 and Q 7 the last DEQUEUE or deletionRear acts on an empty structure, which is underflow and leaves it empty.
- Swapping the deque ends: in Q 7,
deletionFront()removes the left value, not the right. Label each step with the end it touches. - Reversing the fill-in order: in Q 1 part (e) a queue keeps order, so A, S, D, F come out as A, S, D, F, not reversed like a stack.
How to Use the Queue NCERT Solutions PDF for Board Prep
The Queue chapter is short but trap-heavy, mostly around the two ends. The best approach is two passes: one for the FIFO concept and the Python methods, one for tracing the queue and deque operations by hand.
First pass: concept and methods (1 hour)
Read the chapter and note the FIFO rule, the overflow versus underflow pair, and the two list methods append() and pop(0). Write one line of meaning next to each so the words stick before you start tracing.
Second pass: trace the operations (1.5 to 2 hours)
Work Q 6 and Q 7 on paper first, drawing the queue and the deque after every operation with the front on the left. Then open these solutions and check your traces. Pay attention to the peek rule and to the underflow calls near the end, because these two specifics decide full marks.
JEE and CUET angle
For students preparing competitive exams, queues and deques appear in data-structure questions in JEE-level programming rounds and in CUET Computer Science. FIFO scheduling and palindrome checks are exactly the kind of questions those papers reuse, so the work here doubles as competitive prep.
Previous Year Question Trends from the Queue Chapter
The Queue chapter is tested in CBSE board papers mainly through trace questions and a program on the shuttlecock box or a palindrome. The table below maps the asked question types across recent board papers.
| Year | Question type asked | Marks |
|---|---|---|
| 2025 | Show the status of a queue after each operation; define underflow | 3 + 1 |
| 2024 | Menu driven queue program; difference between queue and deque | 4 + 2 |
| 2023 | Compare and contrast queue with stack | 3 |
| 2022 | State FIFO; palindrome check using a deque | 1 + 4 |
| 2021 | Fill in the blanks on ENQUEUE and DEQUEUE; deque trace | 2 + 3 |
Also Check: The full set of CBSE board paper questions for this chapter is included in the downloadable PDF above, updated for the 2026-27 cycle.
Other Resources for Class 12 Computer Science Chapter 4 Queue
Pair this NCERT Solutions PDF with the matching revision notes, handwritten notes and the official NCERT book chapter. All resources for Class 12 Computer Science Chapter 4 Queue are linked below.
| Resource | What it covers | Open |
|---|---|---|
| NCERT Solutions | Step-by-step answers to all 8 exercise questions, with an Expert Solution for each. | You are here |
| Notes | Concept-first revision notes on FIFO, ENQUEUE and DEQUEUE, deque, and the queue applications. | Class 12 Computer Science Chapter 4 Notes |
| Handwritten Notes | Scanned-style handwritten pages for last-minute board revision. | Class 12 Computer Science Chapter 4 Handwritten Notes |
| NCERT Book PDF | Official NCERT Computer Science Chapter 4 Queue textbook in PDF form. | Class 12 Computer Science Chapter 4 NCERT Book PDF |
NCERT Solutions for Class 12 Computer Science: All Chapters
Related Links: Use the table below to open the NCERT Solutions for the other chapters of Class 12 Computer Science. Every chapter ships with the same step-by-step answer style, full PDF download, and revision FAQ.
| Chapter | NCERT Solutions link |
|---|---|
| Chapter 1 | Exception Handling in Python NCERT Solutions |
| Chapter 2 | File Handling in Python NCERT Solutions |
| Chapter 3 | Stack NCERT Solutions |
| Chapter 4 | Queue NCERT Solutions (You are here) |
| Chapter 5 | Sorting NCERT Solutions |
| Chapter 6 | Searching NCERT Solutions |
| Chapter 7 | Understanding Data NCERT Solutions |
| Chapter 8 | Database Concepts NCERT Solutions |
| Chapter 9 | Structured Query Language (SQL) NCERT Solutions |
| Chapter 10 | Computer Networks NCERT Solutions |
| Chapter 11 | Data Communication NCERT Solutions |
| Chapter 12 | Security Aspects NCERT Solutions |
All NCERT Solutions for Class 12 Computer Science Chapter 4 Queue with Step-by-Step Solutions
Fill in the blanks:
a) ____ is a linear list of elements in which insertion and deletion takes place from different ends.
b) Operations on a queue are performed in ____ order.
c) Insertion operation in a queue is called ____ and deletion operation in a queue is called ____.
d) Deletion of elements is performed from ____ end of the queue.
e) Elements 'A', 'S', 'D' and 'F' are present in the queue, and they are deleted one at a time, ____ is the sequence of element received.
f) ____ is a data structure where elements can be added or removed at either end, but not in the middle.
g) A deque contains 'z', 'x', 'c', 'v' and 'b'. Elements received after deletion are 'z', 'b', 'v', 'x' and 'c'. ____ is the sequence of deletion operation performed on deque.
Compare and contrast queue with stack.
How does FIFO describe queue?
Write a menu driven python program using queue, to implement movement of shuttlecock in its box.
How is queue data type different from deque data type?
Show the status of queue after each operation:
enqueue(34)
enqueue(54)
dequeue()
enqueue(12)
dequeue()
enqueue(61)
peek()
dequeue()
dequeue()
dequeue()
dequeue()
enqueue(1)Show the status of deque after each operation:
peek()
insertFront(12)
insertRear(67)
deletionFront()
insertRear(43)
deletionRear()
deletionFront()
deletionRear()Write a python program to check whether the given string is palindrome or not, using deque. (Hint: refer to algorithm 4.1)
NCERT Solutions Class 12 Computer Science Chapter 4 Queue FAQs
Ques. How many questions are there in NCERT Class 12 Computer Science Chapter 4 Queue?
Ans. There are 8 end-of-chapter exercise questions in NCERT Class 12 Computer Science Chapter 4 Queue. All 8 are solved with full answers and an Expert Solution in the PDF. The mix is one fill-in-the-blanks block, one compare and contrast question on queue versus stack, one short question on FIFO, two program questions (a menu driven shuttlecock box and a palindrome check), one queue trace, one deque trace, and one queue versus deque difference question.
Ques. What is the difference between overflow and underflow in a queue?
Ans. Overflow happens when you try to ENQUEUE a new element onto a queue that is already full and has no free space. Underflow happens when you try to DEQUEUE an element from a queue that is already empty. The simple way to remember it is that ENQUEUE alone can cause overflow, because only ENQUEUE adds elements, and DEQUEUE alone can cause underflow, because only DEQUEUE removes them. In Question 6, the two dequeue calls on the empty queue both cause underflow and leave the queue empty.
Ques. How do you implement a queue using a Python list in Class 12 Computer Science?
Ans. Use a Python list as the queue. ENQUEUE is append(x), which adds the new element at the end of the list, acting as the rear. DEQUEUE is pop(0), which removes and returns the element at index 0, acting as the front. PEEK is queue[0], which reads the front without removing it, and len(queue)==0 tests whether the queue is empty. The important rule is to use pop(0) and not plain pop(), because pop() removes the rear and would behave like a stack.
Ques. What is the difference between a queue and a deque?
Ans. A queue is a linear structure with two fixed jobs: it inserts only at the rear (ENQUEUE) and deletes only at the front (DEQUEUE), so it follows strict FIFO and has just two operations. A deque, or double ended queue, allows both insertion and deletion at either end, the front or the rear, but never the middle, so it has four operations: insertFront, insertRear, deletionFront, and deletionRear. A deque is more flexible and can act as a queue or a stack, which makes a plain queue a restricted deque.
Ques. How do you check whether a string is a palindrome using a deque?
Ans. First push every character of the string into the deque with append(). Then run a loop while the deque has more than one character: remove the front character with pop(0) and the rear character with pop(), and compare them. If any pair is unequal, the string is not a palindrome. If the loop ends with no mismatch, with zero or one character left, the string is a palindrome. The loop condition len(dq) greater than 1 handles both even and odd length strings, and for MADAM the program reports a palindrome.
Ques. How many pages is the Class 12th Computer Science Queue NCERT Solutions PDF?
Ans. The Queue NCERT Solutions PDF runs about 18 pages and covers all 8 exercise questions with step-by-step Python code, dry-run traces, queue and deque diagrams, and an Expert Solution for each question. Both Normal and HD versions are available from this page, and both are free to download for the 2026-27 session.
Ques. Is the NCERT Solutions for Class 12 Computer Science Chapter 4 aligned with the 2026-27 syllabus?
Ans. Yes. This page reflects the current 2026-27 CBSE syllabus for Class 12 Computer Science. The Queue chapter is unchanged for the current cycle, and every answer follows the NCERT textbook, including algorithm 4.1 for the deque-based palindrome check. The solutions are useful for the CBSE board exam, and the same data-structure ideas help with JEE-level programming and CUET Computer Science.
Ques. Why does a queue keep the order of elements unchanged?
Ans. A queue keeps the order because of the FIFO rule, which means First In, First Out. Every new element joins only at the rear and every removal takes only the front element, so the oldest waiting element always leaves next. Because nothing can jump the line, the exit order is always the same as the entry order. This is why, in Question 1 part (e), the elements A, S, D, F are received in the same order A, S, D, F, unlike a stack which would reverse them to F, D, S, A.








Comments