Professional Documents
Culture Documents
DS Practical 5 Shardul Vanage (IOT)
DS Practical 5 Shardul Vanage (IOT)
Navi Mumbai
Department of Computer Engineering
Academic Year (2021-2022
(Odd -SEM) (CBCGS- R19- ‘C’ Scheme)
Experiment No:05
Title of Experiment: To Implement Stack Operation Using
. Linked List
Year/Semester: DSE/III
#include <bits/stdc++.h>
using namespace std;
struct Node
{
int data;
struct Node* link;
};
if (!temp)
{
cout << "\nHeap Overflow";
exit(1);
}
temp->data = data;
temp->link = top;
top = temp;
}
int isEmpty()
{
return top == NULL;
}
int peek()
{
void pop()
{
struct Node* temp;
top = top->link;
temp->link = NULL;
free(temp);
}
}
void display()
{
struct Node* temp;
if (top == NULL)
{
cout << "\nStack Underflow";
exit(1);
}
else
{
temp = top;
while (temp != NULL)
{
cout << temp->data << "-> ";
temp = temp->link;
}
}
int main()
{
return 0;
}
Output: