---
type: "Chapter"
knowledge_type: "chapter"
entity_type: "chapter"
id: "66def9a53f8b4e9e69bdbd85"
title: "Stack"
board: "CBSE"
curriculum: "CBSE"
class: "Class 12"
subject: "Computer Science"
book: "Computer Science"
chapter: "Stack"
chapter_slug: "stack"
canonical_url: "https://www.edzy.ai/cbse-class-12-computer-science-stack"
markdown_url: "https://www.edzy.ai/okf/chapter/cbse-class-12-computer-science-stack.md"
source_type: "examSubjectBookChapter"
source_id: "66def9a53f8b4e9e69bdbd85"
source_pdf: "https://edzy-ai.s3.ap-south-1.amazonaws.com/edzy-express-ts/7304af41-953e-471e-9945-f6aad6acde97.pdf"
source: "Edzy"
version: 1
last_updated: "2026-06-20"
---

# Stack

In this chapter, we explore the concept of a stack, a linear data structure that follows the Last-In-First-Out (LIFO) principle. Elements are added and removed from the same end referred to as the top of the stack. We will discuss the operations associated with stacks, their implementation in Python, and applications including the conversion of arithmetic expressions and evaluation of postfix expressions.

---

## Knowledge Snapshot

| Field | Details |
| :--- | :--- |
| Class | Class 12 |
| Subject | Computer Science |
| Book | Computer Science |
| Chapter | Stack |
| Pages | 39-52 |

---

## Chapter Summary

### Short Summary
This chapter introduces the stack data structure, its operations, and implementation using Python. It also covers notations for arithmetic expressions and methods for converting infix notation to postfix notation, in addition to evaluating postfix expressions.

### Detailed Summary
The chapter discusses how data structures, such as stacks, organize and manage data. A stack works on the LIFO principle, meaning the last inserted element is the first to be removed. Key operations on stacks include PUSH (adding an element) and POP (removing the top element). The chapter details the implementation of stacks in Python through lists, and explores real-world applications as well as scenarios in programming, including string reversal, text editor functions, and web browser history. The chapter also explains how expressions can be categorized into infix, prefix, and postfix notations, providing algorithms for converting infix expressions into postfix form and evaluating these expressions using the stack structure.

---

## Topic-Wise Explanation

### Introduction
The chapter begins with a reminder of data types in Python, explaining the importance of data structures in terms of storing and organizing elements efficiently.

### Stack
A stack is introduced using real-life examples, explaining its characteristics and use cases, particularly concerning the LIFO principle.

### Operations on Stack
This section defines the basic operations of stack—PUSH and POP—and explains their significance in managing stack content.

### Implementation of Stack in Python
The chapter provides a simple guide on implementing stacks using Python lists and details the functions required for stack operations.

### Notations for Arithmetic Expressions
It elaborates on how arithmetic expressions can be represented in different notations, namely infix, prefix, and postfix.

### Conversion from Infix to Postfix Notation
Algorithms for converting infix expressions to postfix notation are discussed, highlighting stack usage in the conversion process.

### Evaluation of Postfix Expression
This section describes the evaluation of postfix expressions, using algorithms to define the procedure.

---

## Core Ideas

| Idea | Explanation |
| :--- | :--- |
| Stack Structure | A stack allows for adding and removing elements from one end, adhering to the LIFO principle. |
| Stack Operations | Primary operations include PUSH for adding elements and POP for removing the top element. |
| Python Implementation | Stacks can be implemented in Python using lists with built-in methods for managing elements. |
| Expression Notations | Arithmetic expressions can be represented as infix, postfix, or prefix, each serving different computational needs. |
| Expression Conversion | A stack facilitates the conversion of infix expressions to postfix notation through systematic processing. |

---

## Key Concepts

| Concept | Meaning |
| :--- | :--- |
| LIFO | Last-In-First-Out order of stack operations. |
| PUSH | Operation to add an element to the stack's top. |
| POP | Operation to remove the top element from the stack. |
| Stack Overflow | Error condition when trying to add to a full stack. |
| Stack Underflow | Error condition when trying to remove from an empty stack. |

---

## Important Points for Revision

* A stack is a linear data structure implementing the LIFO principle.
* The PUSH operation adds an element to the top of the stack.
* The POP operation removes the topmost element of the stack.
* In Python, list structures are often used to represent stacks.
* Stacks enable easy reversal of strings and manage browsing history in web browsers.
* Different notations (infix, prefix, postfix) are used for arithmetic expressions to indicate the order of operations.
* The conversion of infix expressions to postfix expressions is done using stacks to maintain operator precedence.
* Evaluating postfix expressions can be efficiently handled using stack operations.

---

## Practice Questions

### Short Answer Questions
1. What is a stack and how does it work?
2. Describe the PUSH and POP operations.
3. How is a stack implemented in Python?
4. What is the significance of the LIFO principle?
5. Explain the process of infix to postfix conversion using a stack.

### Long Answer Questions
1. Compare and contrast infix, prefix, and postfix notations with examples.
2. Discuss the applications of stacks in programming and real-life scenarios.
3. Explain the algorithms for converting infix expressions to postfix expressions step-by-step.

---

## Source Attribution

| Field | Value |
| :--- | :--- |
| Source | Edzy |
| Reference Type | examSubjectBookChapter |
| Reference ID | 66def9a53f8b4e9e69bdbd85 |
| Canonical URL | https://www.edzy.ai/cbse-class-12-computer-science-stack |
| Markdown URL | https://www.edzy.ai/okf/chapter/cbse-class-12-computer-science-stack.md |
