Core9X
Log inSign up

MBOSE Class XII Computer Science · Chapter 4

Queue

Opening soon

How a queue works on the first-in, first-out rule, how to build queues and deques in Python, and where they are used.

14 lessons · 56 practice questions · unit "Computational Thinking and Programming" carries 40 marks

See classes open nowLog inMBOSE Class XII opens to new students soon.

What this chapter covers

  • Queue and FIFO
  • Applications
  • Operations — enqueue, dequeue, isEmpty, peek, isFull, size
  • Implementation in Python
  • Deque — operations, applications and implementation
  • Palindrome checking with a deque

Key terms

Queue

Linear list with insertion at the rear and deletion at the front

FIFO

First In, First Out

FRONT

End from which elements are removed

REAR

End at which elements are added

Enqueue

Adding an element at the rear

Dequeue

Removing the element at the front

Peek

Viewing the front element without removing it

Deque

Double-ended queue — insertion and deletion at both ends

Important questions with answers

10 of the 56 questions on this chapter, solved.

  1. Question 1 · Multiple choice · 1 mark

    A queue follows the principle of

    • (a) FIFO
    • (b) LIFO
    • (c) random order
    • (d) priority only

    Answer: (a) FIFO

    First In, First Out.

  2. Question 2 · Multiple choice · 1 mark

    A, S, D and F are enqueued in that order. Which is dequeued first?

    • (a) F
    • (b) D
    • (c) S
    • (d) A

    Answer: (d) A

    The first in is the first out.

  3. Question 3 · Multiple choice · 1 mark

    isEmpty should be checked before

    • (a) dequeue
    • (b) enqueue only
    • (c) printing the program
    • (d) creating the queue

    Answer: (a) dequeue

    To avoid underflow.

  4. Question 4 · Multiple choice · 1 mark

    Deque stands for

    • (a) double-ended queue
    • (b) deleted queue
    • (c) dynamic equation
    • (d) direct queue

    Answer: (a) double-ended queue

    It is pronounced "deck".

  5. Question 5 · Assertion and reason · 1 mark

    Assertion (A): The first person in a bank queue is served first.

    Reason (R): A queue follows FIFO.

    • (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.

    Answer: (a) Both A and R are true, and R is the correct explanation of A.

    First in, first out.

  6. Question 6 · Short answer · 2 marks

    Define a queue.

    Answer

    A linear list in which elements are added at the rear and removed from the front, following FIFO.

  7. Question 7 · Short answer · 2 marks

    Write Python statements for enqueue and dequeue.

    Answer

    q.append(x) and q.pop(0).

  8. Question 8 · Short answer · 3 marks

    Distinguish isEmpty and isFull.

    Answer

    isEmpty checks for no elements (before dequeue); isFull checks for no space (before enqueue).

  9. Question 9 · Long answer · 5 marks

    Explain the queue, its operations and its Python implementation.

    Answer

    Sections 1.1–1.4.

  10. Question 10 · Long answer · 5 marks

    Write a menu-driven program for a queue.

    Answer

    Section 1.4; Exercise Q4.

Study the whole chapter

14 step-by-step lessons, all 56 practice questions with hints, flashcards and mock tests for MBOSE Class XII Computer Science.

See classes open nowLog inMBOSE Class XII opens to new students soon.