• Wrong document? Swap it for free
  • Written by students who passed
  • Immediately available after payment
  • Read online or as PDF
Sell
Where do you study
Your language
Document preview thumbnail
Preview 2 out of 15 pages
Class notes

Stack ADT & Expressions in Data Structures – Infix, Postfix, Prefix & Expression Conversion Notes

Document preview thumbnail
Preview 2 out of 15 pages

Complete and easy-to-understand Data Structures notes covering the introduction to Stack ADT and expressions. These notes explain important concepts, definitions, types of expressions, and expression conversion techniques in a simple and organized way. Topics covered: Introduction to Stack ADT Expressions in Data Structures Types of Expressions Infix Expression Postfix Expression Prefix Expression Expression Conversion Basic Stack & Expression Concepts These notes are useful for Computer Science and DSA students, especially for exam preparation, assignments, revision, and understanding fundamental data structure concepts.

Content preview

1. Introduction to Stack ADT
1.1 What is a Stack?
A Stack (Abstract Data Type - ADT) is a linear data structure that follows the
principle:

LIFO (Last In, First Out)

This means:

The element inserted last is removed first.

Real-Life Examples

 Stack of plates
 Undo operation in editors
 Function call stack in programming

1.2 Basic Operations of Stack
Operation Description
Push (x) Insert element at top
pop Remove top element
Peek()/top() View top element
isEmpty() Check if stack is empty
IsFull() (Array case) Check overflow


1.3 Stack ADT Definition
Stack is an ADT because:

 It defines what operations are performed
 Not how they are implemented


2. Array Implementation of Stack
2.1 Concept
Stack is implemented using an array with a variable:

 top → index of the top element

Initial Condition:
top = -1

, 2.2 Operations
Push Operation
top = top + 1
stack[top] = value

Pop Operation
value = stack[top]
top = top - 1


2.3 C++ Program (Array Stack)
Question Statement

Write a C++ program to implement stack using array with push, pop, and
display operations.

#include <iostream> // Input/Output ke liye library

using namespace std; // std namespace use karne ke liye

#define SIZE 5 // Stack ka maximum size define kiya (5 elements)

class Stack {

int arr[SIZE]; // Array jo stack ko store karega

int top; // 'top' variable stack ke last element ka index batata hai

public:

// Constructor: jab object banay ga tab yeh automatically call hoga

Stack() {

top = -1; // Initially stack empty hota hai is liye top = -1

}

// Push function: element insert karne ke liye

void push(int x) {

// Check agar stack full ho gaya hai

if (top == SIZE - 1) {

Document information

Uploaded on
October 3, 2026
Number of pages
15
Written in
2026/2027
Type
Class notes
Professor(s)
Zain
Contains
All classes
$3.49

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Sold
0
Followers
0
Items
43
Last sold
-




Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions