Data structures: stacks: practice questions
Class 12 Computer Science. Ten questions with step-by-step answers, for CBSE and ICSE. Try each one before you open its answer.
Key ideas
- Push and pop.
- These are the multi-step questions examiners like to set. Read each one twice, write down what you know, then plan before you calculate.
- These go beyond the syllabus. Each one has a neat idea that makes it short; brute force is slow.
Read each question twice and say the answer out loud before you check it. For code or binary questions, work it out on paper step by step, the way a computer would.
Ten questions
1.push 8, push 7, pop, push 3, pop, pop. Last value popped?
Show the answer
Think: Track the stack after each step.
Work: Last in, first out.
Answer: 8
2.push 1, push 2, pop, push 5, pop, pop. Last value popped?
Show the answer
Think: Track the stack after each step.
Work: Last in, first out.
Answer: 1
3.push 5, push 2, pop, push 8, pop, pop. Last value popped?
Show the answer
Think: Track the stack after each step.
Work: Last in, first out.
Answer: 5
4.push 8, push 4, pop, push 3, pop, pop. Last value popped?
Show the answer
Think: Track the stack after each step.
Work: Last in, first out.
Answer: 8
5.push 6, push 6, pop, push 2, pop, pop. Last value popped?
Show the answer
Think: Track the stack after each step.
Work: Last in, first out.
Answer: 6
6.push 5, push 9, pop, push 8, pop, pop. Last value popped?
Show the answer
Think: Track the stack after each step.
Work: Last in, first out.
Answer: 5
7.push 7, push 6, pop, push 3, pop, pop. Last value popped?
Show the answer
Think: Track the stack after each step.
Work: Last in, first out.
Answer: 7
8.push 1, push 2, pop, push 4, pop, pop. Last value popped?
Show the answer
Think: Track the stack after each step.
Work: Last in, first out.
Answer: 1
9.push 3, push 3, pop, push 1, pop, pop. Last value popped?
Show the answer
Think: Track the stack after each step.
Work: Last in, first out.
Answer: 3
10.push 1, push 2, pop, push 8, pop, pop. Last value popped?
Show the answer
Think: Track the stack after each step.
Work: Last in, first out.
Answer: 1
Before you check an answer
- Track the stack after each step.
Questions students ask
- What does Data structures: stacks in Class 12 Computer Science cover?
- Push and pop. These are the multi-step questions examiners like to set. Read each one twice, write down what you know, then plan before you calculate. These go beyond the syllabus. Each one has a neat idea that makes it short; brute force is slow.
- How should I practise Data structures: stacks?
- Read each question twice and say the answer out loud before you check it. For code or binary questions, work it out on paper step by step, the way a computer would. Try all ten questions on this page, then open the chapter in Gradient tuition for step-by-step lessons, a live experiment and an AI tutor who explains where you went wrong.
- Is this for CBSE or ICSE?
- The questions follow the Class 12 Computer Science syllabus shared by CBSE and ICSE / ISC, and suit most state boards too.
Stuck on one of these?
Gradient tuition teaches Data structures: stacks step by step, with experiments you can play with and an AI tutor who circles the part of the question you missed.
Open Data structures: stacks in tuition