C++ program for array implementation of List ADT

Concept: A linked list is a sequence of data structures, which are connected together via links. Linked List is a sequence of links which contains items. Each link contains a connection to another link. Linked list is the second most-used data structure after array. A linked list is a sequence of data structures, which are connected together via links. Linked List is a sequence of links which contains items. Each link contains a connection to another link. Linked list is the second most-used data structure after array. Following are the important terms to understand the concept of Linked List.

• Link − each link of a linked list can store a data called an element.

• Next − each link of a linked list contains a link to the next link called Next.

• Linked List − A Linked List contains the connection link to the first link called First.

#include
#include
#include
void create();
void insert();
void deletion();
void search();
void display();
int a,b[20],n,d,e,f,i;
void main()
{
int c;
clrscr();

cout<<"\n Main Menu";
cout<<"\n 1.Create \n 2.Delete \n 3.Search \n 4.insert \n
5.Display \n 6.Exit";
do
{
cout<<"\n enter your choice:";
cin>>c;
switch(c)
{
case 1: create(); break;
case 2: deletion(); break;
case 3: search(); break;
case 4: insert(); break;
case 5: display(); break;
case 6: exit(0); break;
default:
cout<<"The given number is not between 1-5\n";
}
}
while(c<=6);
getch();
}
void create()
{
cout<<"\n Enter the number of elements you want to
create: "; cin>>n;
cout<<"\nenter the elements\n";
for(i=0;i
{
cin>>b[i];
}
}
void deletion()
{
cout<<"Enter the number u want to delete \n";
cin>>d;
for(i=0;i
{
if(b[i]==d)
{
b[i]=0;
cout<
}
}
}
void search()
{
cout<<"Enter the number \n";
cin>>e;
for(i=0;i
{
if(b[i]==e)
{
cout<<"Value found the position\n"<
}

}
}
void insert()
{
cout<<"\nenter how many number u want to insert: ";
cin>>f;
cout<<"\nEnter the elements\n";
for(i=0;i
{
cin>>b[n++];
}
}
void display()
{
for(i=0;i
{
#include
#include
#include
void create();
void insert();
void deletion();
void search();
void display();
int a,b[20],n,d,e,f,i;
void main()
{
int c;
clrscr();

cout<<"\n Main Menu";
cout<<"\n 1.Create \n 2.Delete \n 3.Search \n 4.insert \n
5.Display \n 6.Exit";
do
{
cout<<"\n enter your choice:";
cin>>c;
switch(c)
{
case 1: create(); break;
case 2: deletion(); break;
case 3: search(); break;
case 4: insert(); break;
case 5: display(); break;
case 6: exit(0); break;
default:
cout<<"The given number is not between 1-5\n";
}
}
while(c<=6);
getch();
}
void create()
{
cout<<"\n Enter the number of elements you want to
create: "; cin>>n;
cout<<"\nenter the elements\n";
for(i=0;i
{
cin>>b[i];
}
}
void deletion()
{
cout<<"Enter the number u want to delete \n";
cin>>d;
for(i=0;i
{
if(b[i]==d)
{
b[i]=0;
cout<
}
}
}
void search()
{
cout<<"Enter the number \n";
cin>>e;
for(i=0;i
{
if(b[i]==e)
{
cout<<"Value found the position\n"<
}

}
}
void insert()
{
cout<<"\nenter how many number u want to insert: ";
cin>>f;
cout<<"\nEnter the elements\n";
for(i=0;i
{
cin>>b[n++];
}
}
void display()
{
for(i=0;i
{
cout<<"\n"<<b[i];
}
}

Leave a Reply