NCERT Solutions Class 12 Computer Science Chapter 4 Queue
CBSE Class 12 Computer Science - Queue Programming Questions with C++ Solutions
1
Question
Define member function delque() to perform delete operation on a linked queue where each node has the following structure:
Answer
The delque() function removes and displays the front node from the linked queue. Here's the implementation:
This function checks if the queue is not empty, displays the data of the front node, updates the front pointer, deletes the old front node, and handles the case when the queue becomes empty.
2
Question
Give the necessary declaration of linked implemented Queue containing players information. Also write a user defined function in C++ to delete one Player's information from the Queue.
Answer
Here's the function to delete a player's information from the queue:
This function removes the front player from the queue and returns the updated front pointer.
3
Question
Write a function QDELETE() in C++ to perform delete operation on a Linked Queue, which contains Passenger no and Passenger name. Consider the following definition of Node in the code:
Answer
Function to delete passenger information from the linked queue:
This function removes the front passenger from the queue and deallocates the memory.
4
Question
Write a function QINSERT() in C++ to perform insert operation on a Linked Queue, which contains Client no and Client name. Consider the following definition of NODE:
Answer
Function to insert client information into the linked queue:
This function creates a new node, assigns the client data, and adds it to the rear of the queue.
5
Question
Write a function in C++ to perform Insert operation in a circular Queue containing Player information (represented with the help of an array of structure Player):
Answer
Function to insert player information into a circular queue:
This function maintains the circular property of the queue by linking the rear node to the front.
6
Question
Write a function in C++ to perform insert operation in a static circular queue containing books information (represented with the help of an array of structure BOOK):
Answer
Implementation for static circular queue of books:
This function handles the circular nature of the queue by wrapping around when necessary.
7
Question
Write a function in C++ to perform insert operation in a dynamic queue containing DVDs information (represented with the help of an array of structure DVD).
Answer
Function to insert DVD information into a dynamic queue:
This function dynamically allocates memory for a new DVD node and inserts it at the end of the queue.
8
Question
Write the definition of a member function INSERT() for a class QUEUE in C++, to insert a CUSTOMER in a dynamically allocated Queue of items considering the following code:
Answer
Member function INSERT() for the QUEUE class:
This function creates a new customer node and adds it to the rear of the queue, maintaining both front (F) and rear (R) pointers.
9
Question
Write a function in C++ to perform Insert operation in a circular Queue containing Player information (represented with the help of an array of structure Player).
Answer
Function to insert Player information in a circular queue:
This implementation maintains the circular property by ensuring the rear always points to the front.
15
Question
Write a function to implement a priority queue using arrays. The priority queue should support insertion and deletion based on priority levels.
Answer
Implementation of priority queue using arrays:
This priority queue maintains elements in sorted order based on priority, with higher priority elements at the front.
Key Points to Remember
- Queue follows FIFO (First In First Out) principle
- Front pointer points to the first element, rear pointer points to the last element
- Circular queues efficiently utilize memory by wrapping around
- Dynamic queues use linked lists for flexible memory allocation
- Static queues use arrays with fixed size limitations
- Priority queues serve elements based on priority rather than insertion order
- Always check for empty/full conditions before operations
- Proper memory management is crucial in dynamic implementations
Queue Applications and Concepts
Queues are fundamental data structures with numerous real-world applications:
Common Applications
- CPU scheduling in operating systems
- Printer queue management
- Breadth-First Search (BFS) algorithms
- Buffer for data streams
- Handling requests in web servers
Types of Queues
- Simple Queue: Basic FIFO implementation
- Circular Queue: Efficient memory utilization
- Priority Queue: Elements served based on priority
- Deque: Double-ended queue (insertion/deletion at both ends)
Time Complexity
- Enqueue (Insert): O(1)
- Dequeue (Delete): O(1)
- Front/Rear access: O(1)
- Search: O(n)
Understanding these queue implementations is essential for:
- CBSE Class 12 Computer Science examinations
- Competitive programming contests
- Software development projects
- Algorithm design and analysis
- System design interviews

