Skip to main content
Chapter 3 of 13
NCERT Solutions

Stack

CBSE · Class 12 · Computer Science

NCERT Solutions for Stack — CBSE Class 12 Computer Science.

105 questions68 flashcards5 concepts

Interactive on Super Tutor

Studying Stack? Get the full interactive chapter.

Quizzes, flashcards, AI doubt-solver and a step-by-step study plan — built for ncert solutions and more.

1,000+ Class 12 students started this chapter today

An infographic illustrating various data structures like String, List, Set, Tuple, Array, Linked List, Binary Trees, Heaps, Graph, Sparse Matrix, and highlighting linear vs. non-linear structures.
Super Tutor

Super Tutor has 10+ illustrations like this for Stack alone — flashcards, concept maps, and step-by-step visuals.

See them all
11 Questions Solved · 1 Section

6 worked solutions below. Unlock all 11 free in Super Tutor

EXERCISE

1aStack is a linear data structureShow solution
A stack is a linear data structure because its elements are arranged in a sequence, and insertion/deletion happen from one end only.

Not sure why a step works? check your working in Super Tutor

1bStack does not follow LIFO ruleShow solution
A stack follows the LIFO principle, so the statement that it does not follow LIFO is incorrect.

Not sure why a step works? check your working in Super Tutor

1cPUSH operation may result into underflow conditionShow solution
PUSH is an insertion operation. Underflow happens when we try to POP from an empty stack, not when we push.

Not sure why a step works? check your working in Super Tutor

1dIn POSTFIX notation for expression, operators are placed after operandsShow solution
In postfix notation, the operators are written after the operands.

Not sure why a step works? check your working in Super Tutor

2aFind the output of the following code:Show solution
Start with `result = 0` and `numberList = [10,20,30]`.

- `numberList.append(40)` makes the list `[10,20,30,40]`
- First `pop()` gives `40`, so `result = 0 + 40 = 40`
- Second `pop()` gives `30`, so `result = 40 + 30 = 70`

So the output is `Result= 70`.

Not sure why a step works? check your working in Super Tutor

2bFind the output of the following code:Show solution
The list acts as a stack:

- `answer.append('T')` → `['T']`
- `answer.append('A')` → `['T','A']`
- `answer.append('M')` → `['T','A','M']`

Now popping removes from the top:

- `pop()` gives `M` → `output = "M"`
- `pop()` gives `A` → `output = "MA"`
- `pop()` gives `T` → `output = "MAT"`

So the printed result is `Result= MAT`.

Not sure why a step works? check your working in Super Tutor

3Write a program to reverse a string using stack.
4For the following arithmetic expression:
5Evaluate following postfix expressions while showing status of stack after each operation given A=3, B=5, C=1, D=4
6Convert the following infix notations to postfix notations, showing stack and string contents at each step.
7Write a program to create a Stack for storing only odd numbers out of all the numbers entered by the user. Display the content of the Stack along with the largest odd number in the Stack. (Hint. Keep popping out the elements from stack and maintain the largest element retrieved so far in a variable. Repeat till Stack is empty)

5 more solved questions in Stack

Every remaining exercise is solved step by step in Super Tutor, plus practice quizzes and flashcards for this chapter. Free to start.

Stuck on a step?

Ask Super Tutor AI to explain any solution on this page in a simpler way — free, 24x7.

Ask a Doubt Free

Frequently Asked Questions

What are the important topics in Stack for CBSE Class 12 Computer Science?
Stack covers several key topics that are frequently asked in CBSE Class 12 board exams. Focus on the core concepts listed on this page and practise related questions to build confidence.
How to score full marks in Stack — CBSE Class 12 Computer Science?
Understand the core concepts first, then work through the 105 practice questions available for this chapter. Revise formulas and definitions regularly, and use flashcards for quick recall before the exam.
Where can I get free NCERT Solutions for Stack Class 12 Computer Science?
This page has free step-by-step NCERT Solutions for every exercise question in Stack (CBSE Class 12 Computer Science) — written the way examiners award marks: given, formula, working, answer.

Sources & Official References

Content is aligned to the official syllabus. Refer to the board website for the latest curriculum.

For serious students

Get the full Stack chapter — for free.

Quizzes, flashcards, AI doubt-solver and a step-by-step study plan for CBSE Class 12 Computer Science.