0% found this document useful (0 votes)
6 views

STK Linklist

Uploaded by

lsomesh448
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

STK Linklist

Uploaded by

lsomesh448
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Name: Mohini Vilas Narkhede

Roll no.: 80
Practical no:
Title: Implementation of Linked list using Stack.

#include<iostream.h>
#include<conio.h>
class NODE
{
public:
int data;
NODE*link;
};
class STACK
{
NODE*start;
public:
STACK();
void PUSH_80(int);
int POP_80();
int PEEP_80();
void VIEWALL_80();

};
STACK::STACK()
{
start=NULL;
}
void STACK::PUSH_80(int ele)
{
NODE *NN = new NODE(); //step_1 Create new node
NN -> data = ele; //step_2 fill data
NN -> link = NULL;
//set links
if(start==NULL)
start=NN;
else
{
NN->link=start;
start=NN;
}
}
Int STACK:: POP_80()
{
if(start==NULL)
{
cout<<endl<<"List is Empty";
return NULL;
}
else
{
int ele;
ele=start->data;
start=start->link;
return ele;
}
}
int STACK::PEEP_80()
{
if(start==NULL)
{
cout<<endl<<"List is empty";
return NULL;
}
else
{
return start->data;
}
}
void STACK::VIEWALL_80()
{
if(start==NULL)
cout<<endl<<"List is empty";
else
{
NODE *temp_ptr=start;
while(temp_ptr != NULL)
{
cout<<" "<<temp_ptr->data;
temp_ptr=temp_ptr->link;
}
}
}

void MENU()
{
int ch,ele;
STACK s;
do
{
cout<<"\n Select any option";
cout<<"\n 1.PUSH_80";
cout<<"\n 2.POP_80";
cout<<"\n 3.PEEP_80";
cout<<"\n 4.VIEWALL_80";
cout<<"\n 5.EXIT";
cout<<"\n Enter your choice: ";
cin>>ch;

switch(ch)
{
case1 : cout<<endl<<" Enter the element: ";
cin>>ele;
s.PUSH_80(ele);
break;
case2 : cout<<endl<<s.POP_80()<<" is Deleted.";
break;
case3 : cout<<endl<<s.PEEP_80()<<"is the Topmost element";
break;
case4 : cout<<endl<<"The list elements are ";
s.VIEWALL_80()
break;
case5 :return;

default: cout<<endl<<"Invalid choice";


}
}while(1);
}

void main()
{
clrscr();
MENU();
getch();
}

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy