Stacks and Queues

38 MCQs Covers LIFO and FIFO, push and pop, enqueue and dequeue, the queue module, and real-life uses. Includes code-output questions on stacks and queues built with lists and with queue.Queue.

MCQs

38 questions · 35 min · 38 marks

Want to try first? Take the free Computer Science test: SDLC and Waterfall Model

Sample questions

The first 5 of 38. Try each one, then tap to see the answer.

  1. Question 1

    What is the key principle of a stack?

    • AFIFO
    • BLIFO
    • CLILO
    • DFILO
    Show answer

    Answer: B

    Last In, First Out.

  2. Question 2

    Which method adds an item to the stack in Python?

    • Apush()
    • Badd()
    • Cinsert()
    • Dappend()
    Show answer

    Answer: D

    A Python list uses append() as push. (Textbook key.)

  3. Question 3

    Which method removes the top item from the stack?

    • Apop()
    • Bdelete()
    • Cremove()
    • Dclear()
    Show answer

    Answer: A

    pop() removes the last item added.

  4. Question 4

    Which end is used for insertion and deletion in a stack?

    • AFront
    • BEnd
    • CTop
    • DBottom
    Show answer

    Answer: C

    Both operations happen at the top.

  5. Question 5

    Which type of Python structure is used to create a stack?

    • ADictionary
    • BList
    • CString
    • DSet
    Show answer

    Answer: B

    A list works as a stack.

More tests in Computational Structures

Practise with a free account

Save your scores, see which chapters need work, and keep a notebook of every question you got wrong.

Create free account