Which principle does a Queue data structure follow?
(a) LIFO (b) FIFO (c) FILO (d) LILO
In a Queue, new elements are always added at the ______ end.
(a) Front (b) Rear (c) Middle (d) Both ends
Which operation is used to view the element at the front of the queue without removing it?
(a) enqueue (b) dequeue (c) peek (d) isFull
Trying to perform dequeue on an empty queue results in:
(a) Overflow (b) Underflow (c) IndexError (d) None
In Python list implementation of queue, which statement correctly removes an element from the front?
(a) myQueue.pop() (b) myQueue.pop(0) (c) myQueue.append(0) (d) myQueue.insert(0)
Assertion (A): Queue is also known as First Come First Served (FCFS) approach.
Reason (R): The element that enters the queue first is the first one to be removed.
(a) Both A and R are true and R is the correct explanation of A.
(b) Both A and R are true but R is not the correct explanation of A.
(c) A is true but R is false. (d) A is false but R is true.
Assertion (A): Python does not require an isFull() function while implementing queue using list.
Reason (R): Python lists are dynamic and can grow as needed.
(a) Both A and R are true and R is the correct explanation of A.
(b) Both A and R are true but R is not the correct explanation of A.
(c) A is true but R is false. (d) A is false but R is true.
In a deque, insertion and deletion of elements from the same end makes it behave like a:
(a) Queue (b) Stack (c) List (d) None of these
Which of the following is not a valid operation on a deque?
(a) insertFront (b) deletionRear (c) insertMiddle (d) getRear
The function used to check whether a queue contains any element is:
(a) size() (b) isEmpty() (c) peek() (d) enqueue()
python
myQueue = []
enqueue(myQueue, 'A')
enqueue(myQueue, 'B')
print(dequeue(myQueue))
print(size(myQueue))python
def enqueue(myQueue, element):
myQueue.insert(0, element)insertFront(), insertRear(), deletionFront() and isEmpty() to implement a deque using Python list. Also write the main() function to demonstrate all four operations.Case 1: A bank has introduced a digital token system where customers take tokens and wait in a queue to be served at the cash counter. The system must handle arrival of new customers, serving the person at the front, displaying the number of people waiting and checking if the counter is free.
(a) Which data structure is most suitable and why?
(b) Which operation will be performed when a new customer arrives?
(c) Which operation will be performed when the cashier calls the next customer?
(d) Which supporting function should be used before calling the next customer to avoid underflow?
Case 2: A browser maintains history of visited URLs using a deque so that both recently closed and least visited URLs can be managed.
(a) Which two operations of deque will be used to add a new URL and remove the least visited URL?
(b) How can the same deque be used to implement the “Undo” feature in a text editor?
(c) Write the function call to read the most recently visited URL without removing it.
(d) What will happen if deletion is attempted when the deque is empty?
Case 1: (a) Queue (FIFO) (b) enqueue (c) dequeue (d) isEmpty()
Case 2: (a) insertRear & deletionRear (b) insertRear & deletionRear for recent/least visited (c) getRear() (d) Underflow message
All questions are answerable from the NCERT chapter text. Reviewed by GFIS faculty.