Chapter 5 · Class 12 · CBSE · Science Computer Science

Stack

25 practice questions · 5 marks weightage

Topics in this chapter

  • Stack Basics and LIFO Operations
  • Python Stack Implementation
  • Stack Applications and Algorithms
  • Expression Conversion and Evaluation
  • Call Stacks and Recursion

Cheat sheet

Cheat Sheet

Practice questions

  1. Question 1Q-88FC26

    Which principle is followed by a stack data structure?

    1. A.FIFO (First In, First Out)
    2. B.LIFO (Last In, First Out)
    3. C.Random access
    4. D.Priority-based access
    See the answer and solution
  2. Question 2Q-3FD64D

    Consider the following Python code: s = [] def push(x): s.append(x) def pop_item(): if len(s) == 0: return "Underflow" return s.pop() push(10) push(20) push(30) a = pop_item() push(40) b = pop_item() print(a, b, s[-1]) What will be printed?

    1. A.10 20 30
    2. B.30 40 20
    3. C.30 20 40
    4. D.40 30 20
    See the answer and solution
  3. Question 3Q-1EB58E

    What is stack underflow? State one condition that causes it and explain how it can be prevented in a Python implementation.

    See the answer and solution
  4. Question 4Q-5F8FB9

    A stack initially contains [10, 20], with 20 at the top. The operations pop(), push(35), push(40), and pop() are performed in order. What is the top element of the resulting stack?

    1. A.10
    2. B.20
    3. C.35
    4. D.40
    See the answer and solution
  5. Question 5Q-03C01D

    What will be displayed by the following Python code? st = [] for n in [3, 6, 9]: st.append(n) while st: print(st.pop(), end=" ")

    1. A.3 6 9
    2. B.9 6 3
    3. C.3 9 6
    4. D.6 3 9
    See the answer and solution

20 more questions on Stack

Sign up free to practise the full chapter. Questions you get wrong come back until you've mastered them.

Start practising free

Free to start · No credit card needed