Professional Documents
Culture Documents
DS Lab3
DS Lab3
LAB 03
STACK
Stack Rule:
Insertion, Deletion is Possible only from one end. For example, we can place or remove a card or
plate from the top of the stack only. Likewise, Stack ADT allows all data operations at one end
only. At any given time, we can only access the top element of a stack. This feature makes it
LIFO data structure.
Stack Representation:
Basic Operations
QUEUE
Queue Representation
In queue, we access both ends. The following diagram given below tries to explain queue
representation as data structure −
Basic Operations
peek() − Gets the element at the front of the queue without removing it.
LAB TASK
1- Write a C++ Program to implement stack using Arrays. Your Program must have following
functions
void initStack()
int isEmpty()
int isFull()
void push(int num)
void pop()
int peek()
void display()
2- Write a C++ Program to implement queue using Arrays. Write Queue Class in your code.
Your class should have following functions.
Class Queue
{
Queue() //Constructor
bool isEmpty()
bool isFull()
void enqueue(int num)
void dequeue()
void peek()
void display()
}
2- Write main function to test your Queue Class.
REMEMBER: Write your Code using OOP. Yout program should be menu driven.