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 SheetPractice questions
- Question 1Q-88FC26See the answer and solution
Which principle is followed by a stack data structure?
- A.FIFO (First In, First Out)
- B.LIFO (Last In, First Out)
- C.Random access
- D.Priority-based access
- Question 2Q-3FD64DSee the answer and solution
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?
- A.10 20 30
- B.30 40 20
- C.30 20 40
- D.40 30 20
- Question 3Q-1EB58ESee the answer and solution
What is stack underflow? State one condition that causes it and explain how it can be prevented in a Python implementation.
- Question 4Q-5F8FB9See the answer and solution
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?
- A.10
- B.20
- C.35
- D.40
- Question 5Q-03C01DSee the answer and solution
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=" ")
- A.3 6 9
- B.9 6 3
- C.3 9 6
- D.6 3 9
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 freeFree to start · No credit card needed