Stack · Class 12 · CBSE · Science Computer Science
Which principle is followed by a stack data structure?
Practice question from Stack (Class 12 · CBSE · Science Computer Science), with the correct answer and a step-by-step solution.
easy · MCQ · Q-88FC26
Which principle is followed by a stack data structure?
- A.FIFO (First In, First Out)
- B.LIFO (Last In, First Out)Correct answer
- C.Random access
- D.Priority-based access
Solution
A stack follows the LIFO principle: the item inserted last is removed first. The insertion operation is called push, and the deletion operation is called pop.
More from Stack
- Consider the following Python code: s = [] def push(x): s.append(x) def popitem(): if len(s) == 0: return "Underflow" return s.pop() push(1…
- What is stack underflow? State one condition that causes it and explain how it can be prevented in a Python implementation.
- 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 i…
- 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=" ")
Practise more Computer Science
Sign up free for adaptive practice on this chapter, with instant feedback and hints on every question.
Start practising freeFree to start · No credit card needed