Preparing for CBSE Class 12 Board Examination?All chapters — notes, important questions & free quizzesExplore →

Complete Summary and Solutions for Stack – NCERT Class XII Computer Science, Chapter 3 – Introduction, Operations, Applications, Implementation, Questions, Answers

Comprehensive summary and explanation of Chapter 3 'Stack' from the Computer Science textbook for Class XII, covering the concept of stack data structure, stack operations like push and pop, applications of stack, implementation using arrays and linked lists, and use cases in expression evaluation and recursion—along with all NCERT questions, answers, and exercises for effective learning.

Updated: 9 months ago

Categories: NCERT, Class XII, Computer Science, Chapter 3, Stack, Data Structure, Operations, Applications, Summary, Questions, Answers, Programming, Comprehension
Tags: Stack, Data Structure, Push, Pop, Array, Linked List, Recursion, Expression Evaluation, NCERT, Class 12, Computer Science, Summary, Explanation, Questions, Answers, Programming, Chapter 3
Post Thumbnail
Stack in Python - Class 12 Computer Science Chapter 3 Ultimate Study Guide 2025

Stack in Python

Chapter 3: Computer Science - Ultimate Study Guide | NCERT Class 12 Notes, Questions, Code Examples & Quiz 2025

Full Chapter Summary & Detailed Notes - Stack in Python Class 12 NCERT

Overview & Key Concepts

  • Chapter Goal: Understand stack as LIFO data structure, operations (push/pop), Python implementation via list, notations (infix/prefix/postfix), conversion & evaluation using stack. Exam Focus: Algorithms 3.1-3.2, Fig 3.2-3.4, Programs for stack funcs; 2025 Updates: Emphasis on recursion stacks. Fun Fact: Steve Jobs quote on monitoring ties to stack in OS. Core Idea: Efficient LIFO for reversals, expressions. Real-World: Undo in editors, parentheses matching. Expanded: All subtopics point-wise with evidence (e.g., Fig 3.3 steps), examples (e.g., (x+y)/(z*8) → xy+z8*/), debates (e.g., array vs list impl).
  • Wider Scope: From linear DS to applications in compilers; sources: Figs (3.1-3.4), Tables (3.1), Algorithms (3.1-3.2).
  • Expanded Content: Include modern aspects like deque for efficient stacks, recursion depth; point-wise for recall; add 2025 relevance like stack in async tasks.

Introduction & Data Structures

  • Overview: DS organize data for efficient access/ops; linear (stack/queue) vs others (array/tree/graph).
  • Stack Intro: LIFO like plates/books (Fig 3.1); add/remove from top only.
  • Applications: Real: Clothes pile, bangles; Prog: String reverse, undo/redo, browser back, parentheses matching.
  • Example: Undo: Stack tracks changes; pop for undo. Evidence: Traversing string reverse via push/pop.
  • Practical Difficulties: Overflow (full), underflow (empty pop). Solutions: Check size.
  • Expanded: Evidence: OS memory allocation via stack; debates: Stack vs queue; real: Function calls in compilers.
Conceptual Diagram: Stack LIFO Flow

Flow: Empty → Push (top grows) → Pop (top shrinks) → Empty. Ties to Fig 3.2 glasses.

Why This Guide Stands Out

Comprehensive: All subtopics point-wise, program integrations; 2025 with deque variants, processes analyzed for real code.

Operations on Stack

  • Push: Add to top; overflow if full (Fig 3.2 i-ii).
  • Pop: Remove from top; underflow if empty (Fig 3.2 iv,ix).
  • Other: isEmpty, size, top (peek).
  • Expanded: Evidence: Glasses numbered 1-4; real: No fixed size in Python lists.

Implementation in Python

  • Using List: append() for push, pop() for pop; no explicit top.
  • Functions: isEmpty, opPush, size, top, opPop, display (as in text).
  • Example Program: glassStack with push/pop glass1-3; output shows LIFO.
  • Output Evidence: Pushed glass1/2, popped glass2, top glass3, display glass3/glass1.
  • Expanded: Evidence: While loop empty check; debates: List vs collections.deque.

Quick Code: Basic Stack

glassStack = []
glassStack.append('glass1')  # Push
print(glassStack.pop())      # Pop: glass1

Output: glass1 (LIFO)

Notations for Arithmetic Expressions

  • Infix: Op between operands; BODMAS (e.g., x+y).
  • Prefix (Polish): Op before (e.g., +xy); no parens.
  • Postfix (Reverse Polish): Op after (e.g., xy+); single traversal eval.
  • Table 3.1: Examples like 3*(4+5) → *3+45 (prefix), 345+* (postfix).
  • Expanded: Evidence: Lukasiewicz 1920s; real: Calculators use postfix.

Conversion Infix to Postfix

  • Algorithm 3.1: Stack for ops/parens; precedence rules (e.g., * > +).
  • Steps: Push (, pop on ); for op, compare prec & pop/append.
  • Example 3.1: (x + y)/(z*8) → Steps in Fig 3.3; final xy+z8*/.
  • Expanded: Evidence: Left assoc; debates: Handling same prec.

Evaluation of Postfix

  • Algorithm 3.2: Push operands; pop two for op, push result.
  • Example 3.2: 7 8 2 * 4 / + → Steps Fig 3.4; result 11.
  • Expanded: Evidence: Binary ops only; real: Stack machine eval.

Exam Code Studies

Stack funcs; infix "(A+B)*C" → AB+C*; eval "AB+C*" (A=2,B=3,C=4) → 20.

Summary & Exercise

  • Key Takeaways: LIFO stack via list; notations for expr; stack for conv/eval.
  • Exercise Tease: True/False LIFO; code reverse string; convert/eval expr.
This chapter is part of the CBSE Class 12 Board Examination Board ExaminationExplore every chapter — NCERT notes, important questions & MCQ quizzes
Practice Quiz

Test your CBSE Class 12 Board Examination prep

Dual AI-verified questions Real exam pattern 2 quizzes free, then 10 credits per quiz

#1

The Last Lesson

English 10 Qs · ~10 min
8/10avg score
10/10best
#2

Economics (Class 12) Practice Quiz | CBSE Class 12 Board Examination

10 Qs · ~10 min
0.2/10avg score
1/10best
#3

Matrices

Maths 10 Qs · ~10 min
3.8/10avg score
7/10best
#4

Challenges of Nation Building

Political Science 10 Qs · ~10 min
7.7/10avg score
8/10best
#5

Human Geography: Nature and Scope

Geography 10 Qs · ~10 min
5.3/10avg score
8/10best
#6

Bricks, Beads and Bones — The Harappan Civilisation

History 10 Qs · ~10 min
8.7/10avg score
9/10best
#7

Money and Banking

Economics 10 Qs · ~10 min
8.7/10avg score
10/10best
#8

The End of Bipolarity

Political Science 10 Qs · ~10 min
6/10avg score
10/10best
#9

Inverse Trigonometric Functions

Maths 10 Qs · ~10 min
#10

The Enemy

English 10 Qs · ~10 min
10/10avg score
10/10best
#11

Keeping Quiet

English 10 Qs · ~10 min
10/10avg score
10/10best
#12

My Mother at Sixty-six

English 10 Qs · ~10 min
8/10avg score
8/10best
#13

Poets and Pancakes

English 10 Qs · ~10 min
9/10avg score
9/10best
#14

The Rattrap

English 10 Qs · ~10 min
9/10avg score
9/10best
#15

Lost Spring

English 10 Qs · ~10 min
9/10avg score
9/10best
#16

Introducing Indian Society

Sociology 10 Qs · ~10 min
6/10avg score
6/10best
#17

Security in the Contemporary World

Political Science 10 Qs · ~10 min
1/10avg score
1/10best
#18

Tertiary and Quaternary Activities

Geography 10 Qs · ~10 min
9/10avg score
9/10best
#19

Secondary Activities

Geography 10 Qs · ~10 min
8/10avg score
8/10best
#20

Kings, Farmers and Towns — Early States and Economies (c. 600 BCE-600 CE)

History 10 Qs · ~10 min
10/10avg score
10/10best
#21

Theory of Consumer Behaviour

Economics 10 Qs · ~10 min
6/10avg score
6/10best
#22

Introduction

Economics 10 Qs · ~10 min
#23

Staffing

Business Studies 10 Qs · ~10 min
#24

Nature and Significance of Management

Business Studies 10 Qs · ~10 min
6/10avg score
6/10best
#25

Continuity and Differentiability

Maths 10 Qs · ~10 min
1/10avg score
1/10best
#26

Determinants

Maths 10 Qs · ~10 min
7/10avg score
7/10best
#27

Relations and Functions

Maths 10 Qs · ~10 min
#28

Principles of Inheritance and Variation

Biology 10 Qs · ~10 min
10/10avg score
10/10best
#29

Reproductive Health

Biology 10 Qs · ~10 min
9/10avg score
9/10best
#30

Human Reproduction

Biology 10 Qs · ~10 min
10/10avg score
10/10best
#31

Chemical Kinetics

Chemistry 10 Qs · ~10 min
#32

Solutions

Chemistry 10 Qs · ~10 min
7/10avg score
7/10best
#33

Principles of Management

Business Studies 10 Qs · ~10 min
1/10avg score
1/10best
#34

Accountancy (Class 12) Practice Quiz | CBSE Class 12 Board Examination

10 Qs · ~10 min
#35

Electrostatic Potential and Capacitance Fundamentals | CBSE Class 12 Board Examination

10 Qs · ~10 min
3/10avg score
3/10best
#36

Memories of Childhood

English 10 Qs · ~10 min
#37

On the Face of It

English 10 Qs · ~10 min
#38

Journey to the End of the Earth

English 10 Qs · ~10 min
#39

The Tiger King

English 10 Qs · ~10 min
#40

The Third Level

English 10 Qs · ~10 min
#41

Aunt Jennifer's Tigers

English 10 Qs · ~10 min
#42

A Roadside Stand

English 10 Qs · ~10 min
#43

A Thing of Beauty

English 10 Qs · ~10 min
#44

An Elementary School Classroom in a Slum

English 10 Qs · ~10 min
#45

Going Places

English 10 Qs · ~10 min
#46

The Interview

English 10 Qs · ~10 min
#47

Indigo

English 10 Qs · ~10 min
#48

Deep Water

English 10 Qs · ~10 min
#49

Social Influence and Group Processes

Psychology 10 Qs · ~10 min
#50

Attitude and Social Cognition

Psychology 10 Qs · ~10 min
#51

Therapeutic Approaches

Psychology 10 Qs · ~10 min
#52

Psychological Disorders

Psychology 10 Qs · ~10 min
#53

Meeting Life Challenges

Psychology 10 Qs · ~10 min
#54

Self and Personality

Psychology 10 Qs · ~10 min
#55

Variations in Psychological Attributes

Psychology 10 Qs · ~10 min
#56

Social Movements

Sociology 10 Qs · ~10 min
#57

Mass Media and Communications

Sociology 10 Qs · ~10 min
#58

Globalisation and Social Change

Sociology 10 Qs · ~10 min
#59

Change and Development in Industrial Society

Sociology 10 Qs · ~10 min
#60

Change and Development in Rural Society

Sociology 10 Qs · ~10 min
#61

The Constitution and Social Change

Sociology 10 Qs · ~10 min
#62

Cultural Change

Sociology 10 Qs · ~10 min
#63

Structural Change

Sociology 10 Qs · ~10 min
#64

The Challenges of Cultural Diversity

Sociology 10 Qs · ~10 min
#65

Patterns of Social Inequality and Exclusion

Sociology 10 Qs · ~10 min
#66

The Market as a Social Institution

Sociology 10 Qs · ~10 min
#67

Social Institutions: Continuity and Change

Sociology 10 Qs · ~10 min
#68

The Demographic Structure of the Indian Society

Sociology 10 Qs · ~10 min
#69

Recent Developments in Indian Politics

Political Science 10 Qs · ~10 min
#70

Regional Aspirations

Political Science 10 Qs · ~10 min
#71

The Crisis of Democratic Order

Political Science 10 Qs · ~10 min
#72

Challenges to and Restoration of the Congress System

Political Science 10 Qs · ~10 min
#73

India's External Relations

Political Science 10 Qs · ~10 min
#74

Politics of Planned Development

Political Science 10 Qs · ~10 min
#75

Era of One-party Dominance

Political Science 10 Qs · ~10 min
#76

Environment and Natural Resources

Political Science 10 Qs · ~10 min
#77

International Organisations

Political Science 10 Qs · ~10 min
#78

Contemporary South Asia

Political Science 10 Qs · ~10 min
#79

Contemporary Centres of Power

Political Science 10 Qs · ~10 min
#80

Geographical Perspective on Selected Issues and Problems

Geography 10 Qs · ~10 min
#81

Planning and Sustainable Development in the Indian Context

Geography 10 Qs · ~10 min
#82

Mineral and Energy Resources

Geography 10 Qs · ~10 min
#83

Water Resources

Geography 10 Qs · ~10 min
#84

Land Resources and Agriculture

Geography 10 Qs · ~10 min
#85

Human Settlements

Geography 10 Qs · ~10 min
#86

Population: Distribution, Density, Growth and Composition

Geography 10 Qs · ~10 min
#87

International Trade (India)

Geography 10 Qs · ~10 min
#88

Transport and Communication (India)

Geography 10 Qs · ~10 min
#89

Primary Activities

Geography 10 Qs · ~10 min
#90

Human Development

Geography 10 Qs · ~10 min
#91

The World Population: Distribution, Density and Growth

Geography 10 Qs · ~10 min
#92

Framing the Constitution — The Beginning of a New Era

History 10 Qs · ~10 min
#93

Mahatma Gandhi and the Nationalist Movement — Civil Disobedience and Beyond

History 10 Qs · ~10 min
#94

Rebels and the Raj — The Revolt of 1857 and its Representations

History 10 Qs · ~10 min
#95

Colonialism and the Countryside — Exploring Official Archives

History 10 Qs · ~10 min
#96

Peasants, Zamindars and the State — Agrarian Society and the Mughal Empire (c. sixteenth-seventeenth centuries)

History 10 Qs · ~10 min
#97

An Imperial Capital: Vijayanagara (c. fourteenth to sixteenth century)

History 10 Qs · ~10 min
#98

Bhakti-Sufi Traditions — Changes in Religious Beliefs and Devotional Texts (c. eighth to eighteenth century)

History 10 Qs · ~10 min
#99

Through the Eyes of Travellers — Perceptions of Society (c. tenth to seventeenth century)

History 10 Qs · ~10 min
#100

Thinkers, Beliefs and Buildings — Cultural Developments (c. 600 BCE-600 CE)

History 10 Qs · ~10 min
#101

Kinship, Caste and Class — Early Societies (c. 600 BCE-600 CE)

History 10 Qs · ~10 min
#102

Open Economy Macroeconomics

Economics 10 Qs · ~10 min
#103

Government Budget and the Economy

Economics 10 Qs · ~10 min
#104

Determination of Income and Employment

Economics 10 Qs · ~10 min
#105

National Income Accounting

Economics 10 Qs · ~10 min
#106

Market Equilibrium

Economics 10 Qs · ~10 min
#107

The Theory of the Firm under Perfect Competition

Economics 10 Qs · ~10 min
#108

Production and Costs

Economics 10 Qs · ~10 min
#109

Consumer Protection

Business Studies 10 Qs · ~10 min
#110

Marketing

Business Studies 10 Qs · ~10 min
#111

Financial Management

Business Studies 10 Qs · ~10 min
#112

Controlling

Business Studies 10 Qs · ~10 min
#113

Directing

Business Studies 10 Qs · ~10 min
#114

Organising

Business Studies 10 Qs · ~10 min
#115

Planning

Business Studies 10 Qs · ~10 min
#116

Business Environment

Business Studies 10 Qs · ~10 min
#117

Cash Flow Statement

Accountancy 10 Qs · ~10 min
#118

Accounting Ratios

Accountancy 10 Qs · ~10 min
#119

Analysis of Financial Statements

Accountancy 10 Qs · ~10 min
#120

Financial Statements of a Company

Accountancy 10 Qs · ~10 min
#121

Issue and Redemption of Debentures

Accountancy 10 Qs · ~10 min
#122

Accounting for Share Capital

Accountancy 10 Qs · ~10 min
#123

Dissolution of Partnership Firm

Accountancy 10 Qs · ~10 min
#124

Reconstitution of a Partnership Firm – Retirement/Death of a Partner

Accountancy 10 Qs · ~10 min
#125

Reconstitution of a Partnership Firm – Admission of a Partner

Accountancy 10 Qs · ~10 min
#126

Accounting for Partnership: Basic Concepts

Accountancy 10 Qs · ~10 min
#127

Probability

Maths 10 Qs · ~10 min
#128

Linear Programming

Maths 10 Qs · ~10 min
#129

Three Dimensional Geometry

Maths 10 Qs · ~10 min
#130

Vector Algebra

Maths 10 Qs · ~10 min
#131

Differential Equations

Maths 10 Qs · ~10 min
#132

Application of Integrals

Maths 10 Qs · ~10 min
#133

Integrals

Maths 10 Qs · ~10 min
#134

Application of Derivatives

Maths 10 Qs · ~10 min
#135

Biodiversity and its Conservation

Biology 10 Qs · ~10 min
#136

Ecosystem

Biology 10 Qs · ~10 min
#137

Organisms and Populations

Biology 10 Qs · ~10 min
#138

Biotechnology and its Applications

Biology 10 Qs · ~10 min
#139

Biotechnology: Principles and Processes

Biology 10 Qs · ~10 min
#140

Microbes in Human Welfare

Biology 10 Qs · ~10 min
#141

Human Health and Disease

Biology 10 Qs · ~10 min
#142

Evolution

Biology 10 Qs · ~10 min
#143

Molecular Basis of Inheritance

Biology 10 Qs · ~10 min
#144

Sexual Reproduction in Flowering Plants

Biology 10 Qs · ~10 min
#145

Biomolecules

Chemistry 10 Qs · ~10 min
#146

Amines

Chemistry 10 Qs · ~10 min
#147

Aldehydes, Ketones and Carboxylic Acids

Chemistry 10 Qs · ~10 min
#148

Alcohols, Phenols and Ethers

Chemistry 10 Qs · ~10 min
#149

Haloalkanes and Haloarenes

Chemistry 10 Qs · ~10 min
#150

Coordination Compounds

Chemistry 10 Qs · ~10 min
#151

The d- and f-Block Elements

Chemistry 10 Qs · ~10 min
#152

Electrochemistry

Chemistry 10 Qs · ~10 min
#153

Semiconductor Electronics: Materials, Devices and Simple Circuits

Physics 10 Qs · ~10 min
#154

Nuclei

Physics 10 Qs · ~10 min
#155

Atoms

Physics 10 Qs · ~10 min
#156

Dual Nature of Radiation and Matter

Physics 10 Qs · ~10 min
#157

Wave Optics

Physics 10 Qs · ~10 min
#158

Ray Optics and Optical Instruments

Physics 10 Qs · ~10 min
#159

Electromagnetic Waves

Physics 10 Qs · ~10 min
#160

Alternating Current

Physics 10 Qs · ~10 min
#161

Electromagnetic Induction

Physics 10 Qs · ~10 min
#162

Magnetism and Matter

Physics 10 Qs · ~10 min
#163

Moving Charges and Magnetism

Physics 10 Qs · ~10 min
#164

Electrostatic Potential and Capacitance

Physics 10 Qs · ~10 min
#165

Electric Charges and Fields

Physics 10 Qs · ~10 min
#166

CBSE Class 12 — Genetics and Evolution

10 Qs · ~10 min
#167

CBSE Class 12 — Matrices and Determinants

10 Qs · ~10 min
#168

CBSE Class 12 — Solutions and Colligative Properties

10 Qs · ~10 min
#169

Current Electricity

Physics 10 Qs · ~10 min
#170

CBSE Class 12 — Electrostatics and Electric Field

10 Qs · ~10 min
#171

Humanities Subjects Practice Quiz | CBSE Class 12 Board Examination

10 Qs · ~10 min

Group Discussions

No forum posts available.

Easily Share with Your Tribe