DSA-LAB_07 (Stack )
DSA-LAB_07 (Stack )
Objective:
Define Stack and discuss all the operations performed on Stack.
Theory:
In this Lab, we discuss the stack data type. This data type supports Last In, First Out (LIFO)
data access. Contiguous (array) and linked structures are used for implementations.
Basic Operations
Here are the minimal operations we'd need for an abstract stack (and their typical names):
Push( ): Places a value/object on the Top of the stack.
Pop( ): Removes a value/object from the Top of the stack and produces that
value/object.
IsEmpty( ): Reports whether the stack is empty or not.
IsFull( ): Reports whether the stack is Full or not (for array implementation).
Peak( ) : produces Top value/object of the stack without removing it.
Traverse( ) : visit all elements from Top to Bottom without removing them.
Stack data structure can be implemented in two ways. They are as follows:
1. Using Array
2. Using Linked List
Lab Objectives:
Practical # 07 Page 2 of 4
C++ program: Write C++ program to implement stack using Array.
OUTPUT
Practical # 07 Page 3 of 4
Review Questions/ Exercise:
____________________________________________________________ _________________________________________________
3. Write a C++ program that uses stack operations to convert a given infix expression into its
postfix equivalent, Implement the stack using an array.
_______________________________________________________________________________________________________________
Name: _____
Roll #: _____
Date: _____
Subject Teacher
Remarks:
Practical # Page 4 of 4
07