SlideShare a Scribd company logo
Please need help on following program using c++ language. Please include all header files and
main file with their own title.
Extend the class linkedListType by adding the following operations:
Write a function that returns the info of the kth element of the linked list. If no such element
exists, terminate the program.
Write a function that deletes the kth element of the linked list. If no such element exists,
terminate the program.
Provide the definitions of these functions in the class linkedListType. Also, write a program to
test these functions. (Use either the class unorderedLinkedList or the
class orderedLinkedList to test your function.)
Solution
C++ Code for the given problem is below.....
.....................................................
/*
* C++ Program to Implement Singly Linked List
*/
#include
#include
#include
//using namespace std;
/*
* Node Declaration
*/
typedef struct nodetype
{
int info;
nodetype *next ;
} node;
/*
* Class Declaration
*/
class linkedListType
{
public:
void insfrombeg( node **head, int);
void delfromkth(node **head,int);
void findthekthnode(node *head,int);
void traverse(node *head);
int item,ch,kth;
node *ptr,*head,*temp;
};
/*
* Main :contains menu
*/
void main()
{
int item,ch,kth;
node *ptr,*head,*temp;
linkedListType s1;
clrscr();
while (1)
{
while(1)
{
cout<<"PRESS (1) FOR INSERT INTO LIST"<>ch;
switch(ch)
{
case 1:
cout<<"ENTER THE VALUE "<>item;
s1.insfrombeg(&head,item);
break;
case 2:
s1.traverse(head);
break;
case 3:
cout<<"ENTER THE Kth Element which you want's to delete"<>kth;
s1.delfromkth(&head,kth);
break;
case 4:
cout<<"ENTER THE Kth Element which you want's to search  "<>kth;
s1.findthekthnode(head,kth);
break;
case 5:
exit(1);
}
}
// getch();
}
}
/*
* Inserting element in beginning
*/
void linkedListType::insfrombeg(node **head,int item)
{
temp= ( node * ) malloc (sizeof( node ));
temp->info= item;
temp->next= NULL;
if(*head == NULL)
{
temp->next= *head;
*head= temp;
}
else
{
temp->next= *head;
*head= temp;
}
}
/*
* Delete element at a given position
*/
void linkedListType::delfromkth(node **head,int kth)
{ node* temp1=*head,*temp2;
if(*head ==NULL)
{
cout<<"LINK LIST IS EMPTY "<next;
free(temp);
}
else
for(int j=0;jnext;
temp2= temp1->next;
temp1->next=temp2->next;
free(temp2);
}
/*
* Searching an element
*/
void linkedListType::findthekthnode(node *head,int kth)
{
ptr=head;
int i=1;
while((ptr!=NULL))
{
if(i==kth)
{
cout<<" The Element at"<< kth<< "position with value is t
"<info<info<next;
i++;
}
}
}
/*
* Traverse Link List
*/
void linkedListType::traverse(node *head)
{
ptr = head;
while((ptr->next)->next!=NULL)
{
cout<info<<"t";
ptr=ptr->next;
}
cout<
#include
#include
typedef struct nodetype
{
int info;
nodetype *next ;
} node;
int item,ch,kth,total=1;
node *ptr,*head,*temp;
void insfrombeg( node **head, int);
void delfromkth(node **head,int);
void findthekthnode(node *head,int);
void traverse(node *head);
void main()
{
clrscr();
while(1)
{
printf("PRESS (1) FOR INSERT INTO LIST ");
printf("PRESS (2) FOR TRAVERSE FROM INORDER ");
printf("PRESS (3) FOR DELETE FROM kth NODE " );
printf("PRESS (4) FOR FIND THE Kth NODE  " );
printf("PRESS (5) FOR EXIT FROM MENU  ");
printf("ENTER YOUR CHOICE ");
scanf("%d",&ch);
switch(ch)
{
case 1:
printf("ENTER THE VALUE ") ;
scanf("%d",&item);
insfrombeg(&head,item);
break;
case 2:
traverse(head);
break;
case 3:
printf("ENTER THE Kth Element which you want's to delete  ") ;
scanf("%d",&kth);
delfromkth(&head,kth);
break;
case 4:
printf("ENTER THE Kth Element which you want's to search  ");
scanf("%d",&kth);
findthekthnode(head,kth);
break;
case 5:
exit(1);
}
}
// getch();
}
void insfrombeg(node **head,int item)
{
temp= ( node * ) malloc (sizeof( node ));
temp->info= item;
temp->next= NULL;
if(*head == NULL)
{
temp->next= *head;
*head= temp;
}
else
{
temp->next= *head;
*head= temp;
}
}
void findthekthnode(node *head,int kth)
{ ptr=head;
int i=1;
while((ptr!=NULL))
{
if(i==kth)
{
printf(" The Element at %d position with value is %dt",kth,ptr->info);
printf(" ");
break;
}
else
{
printf("%dt",ptr->info);
ptr=ptr->next;
i++;
}
}
}
void delfromkth(node **head,int kth)
{ node* temp1=*head,*temp2;
if(*head ==NULL)
{
printf("LINK LIST IS EMPTY ");
exit;
}
if(kth==1)
{
*head= temp1->next;
free(temp);
}
else
for(int j=0;jnext;
temp2= temp1->next;
temp1->next=temp2->next;
free(temp2);
}
void traverse(node *head)
{
ptr = head;
while(ptr!=NULL)
{
printf("%dt",ptr->info);
ptr=ptr->next;
}
printf(" ");
}

More Related Content

Similar to Please need help on following program using c++ language. Please inc.pdf

Please help solve this in C++ So the program is working fin.pdf
Please help solve this in C++ So the program is working fin.pdfPlease help solve this in C++ So the program is working fin.pdf
Please help solve this in C++ So the program is working fin.pdf
ankit11134
 
C++ Doubly-Linked ListsThe goal of the exercise is to implement a.pdf
C++ Doubly-Linked ListsThe goal of the exercise is to implement a.pdfC++ Doubly-Linked ListsThe goal of the exercise is to implement a.pdf
C++ Doubly-Linked ListsThe goal of the exercise is to implement a.pdf
poblettesedanoree498
 
DSA(1).pptx
DSA(1).pptxDSA(1).pptx
DSA(1).pptx
DaniyalAli81
 
Write a Java Class to Implement a Generic Linked ListYour list mus.pdf
Write a Java Class to Implement a Generic Linked ListYour list mus.pdfWrite a Java Class to Implement a Generic Linked ListYour list mus.pdf
Write a Java Class to Implement a Generic Linked ListYour list mus.pdf
rozakashif85
 
This is problem is same problem which i submitted on 22017, I just.pdf
This is problem is same problem which i submitted on 22017, I just.pdfThis is problem is same problem which i submitted on 22017, I just.pdf
This is problem is same problem which i submitted on 22017, I just.pdf
fcaindore
 
Doublylinklist
DoublylinklistDoublylinklist
Doublylinklistritu1806
 
Lab Week 2 Game Programming.docx
Lab Week 2 Game Programming.docxLab Week 2 Game Programming.docx
Lab Week 2 Game Programming.docx
teyaj1
 
Help please!!(Include your modified DList.java source code file in.pdf
Help please!!(Include your modified DList.java source code file in.pdfHelp please!!(Include your modified DList.java source code file in.pdf
Help please!!(Include your modified DList.java source code file in.pdf
jyothimuppasani1
 
Implement the following specification of UnsortedType using circular.pdf
Implement the following specification of UnsortedType using circular.pdfImplement the following specification of UnsortedType using circular.pdf
Implement the following specification of UnsortedType using circular.pdf
udit652068
 
Implement the unsorted single linked list as we did in the class and .pdf
Implement the unsorted single linked list as we did in the class and .pdfImplement the unsorted single linked list as we did in the class and .pdf
Implement the unsorted single linked list as we did in the class and .pdf
arihantstoneart
 
please help me in C++Objective Create a singly linked list of num.pdf
please help me in C++Objective Create a singly linked list of num.pdfplease help me in C++Objective Create a singly linked list of num.pdf
please help me in C++Objective Create a singly linked list of num.pdf
aminbijal86
 
Using the C++ programming language1. Implement the UnsortedList cl.pdf
Using the C++ programming language1. Implement the UnsortedList cl.pdfUsing the C++ programming language1. Implement the UnsortedList cl.pdf
Using the C++ programming language1. Implement the UnsortedList cl.pdf
mallik3000
 
To complete the task, you need to fill in the missing code. I’ve inc.pdf
To complete the task, you need to fill in the missing code. I’ve inc.pdfTo complete the task, you need to fill in the missing code. I’ve inc.pdf
To complete the task, you need to fill in the missing code. I’ve inc.pdf
ezycolours78
 
implement the ListLinked ADT (the declaration is given in ListLinked.pdf
implement the ListLinked ADT (the declaration is given in ListLinked.pdfimplement the ListLinked ADT (the declaration is given in ListLinked.pdf
implement the ListLinked ADT (the declaration is given in ListLinked.pdf
FOREVERPRODUCTCHD
 
Adt of lists
Adt of listsAdt of lists
Adt of lists
Nivegeetha
 
Write a C++ function that delete nodes in a doubly linkedlist- It shou.docx
Write a C++ function that delete nodes in a doubly linkedlist- It shou.docxWrite a C++ function that delete nodes in a doubly linkedlist- It shou.docx
Write a C++ function that delete nodes in a doubly linkedlist- It shou.docx
noreendchesterton753
 
Write a program that accepts an arithmetic expression of unsigned in.pdf
Write a program that accepts an arithmetic expression of unsigned in.pdfWrite a program that accepts an arithmetic expression of unsigned in.pdf
Write a program that accepts an arithmetic expression of unsigned in.pdf
JUSTSTYLISH3B2MOHALI
 
Below is a depiction of a doubly-linked list implementation of the bag.docx
Below is a depiction of a doubly-linked list implementation of the bag.docxBelow is a depiction of a doubly-linked list implementation of the bag.docx
Below is a depiction of a doubly-linked list implementation of the bag.docx
gilliandunce53776
 
How do you stop infinite loop Because I believe that it is making a.pdf
How do you stop infinite loop Because I believe that it is making a.pdfHow do you stop infinite loop Because I believe that it is making a.pdf
How do you stop infinite loop Because I believe that it is making a.pdf
feelinggift
 

Similar to Please need help on following program using c++ language. Please inc.pdf (20)

Please help solve this in C++ So the program is working fin.pdf
Please help solve this in C++ So the program is working fin.pdfPlease help solve this in C++ So the program is working fin.pdf
Please help solve this in C++ So the program is working fin.pdf
 
C++ Doubly-Linked ListsThe goal of the exercise is to implement a.pdf
C++ Doubly-Linked ListsThe goal of the exercise is to implement a.pdfC++ Doubly-Linked ListsThe goal of the exercise is to implement a.pdf
C++ Doubly-Linked ListsThe goal of the exercise is to implement a.pdf
 
DSA(1).pptx
DSA(1).pptxDSA(1).pptx
DSA(1).pptx
 
Write a Java Class to Implement a Generic Linked ListYour list mus.pdf
Write a Java Class to Implement a Generic Linked ListYour list mus.pdfWrite a Java Class to Implement a Generic Linked ListYour list mus.pdf
Write a Java Class to Implement a Generic Linked ListYour list mus.pdf
 
This is problem is same problem which i submitted on 22017, I just.pdf
This is problem is same problem which i submitted on 22017, I just.pdfThis is problem is same problem which i submitted on 22017, I just.pdf
This is problem is same problem which i submitted on 22017, I just.pdf
 
Doublylinklist
DoublylinklistDoublylinklist
Doublylinklist
 
Lab Week 2 Game Programming.docx
Lab Week 2 Game Programming.docxLab Week 2 Game Programming.docx
Lab Week 2 Game Programming.docx
 
Help please!!(Include your modified DList.java source code file in.pdf
Help please!!(Include your modified DList.java source code file in.pdfHelp please!!(Include your modified DList.java source code file in.pdf
Help please!!(Include your modified DList.java source code file in.pdf
 
Implement the following specification of UnsortedType using circular.pdf
Implement the following specification of UnsortedType using circular.pdfImplement the following specification of UnsortedType using circular.pdf
Implement the following specification of UnsortedType using circular.pdf
 
Implement the unsorted single linked list as we did in the class and .pdf
Implement the unsorted single linked list as we did in the class and .pdfImplement the unsorted single linked list as we did in the class and .pdf
Implement the unsorted single linked list as we did in the class and .pdf
 
please help me in C++Objective Create a singly linked list of num.pdf
please help me in C++Objective Create a singly linked list of num.pdfplease help me in C++Objective Create a singly linked list of num.pdf
please help me in C++Objective Create a singly linked list of num.pdf
 
Using the C++ programming language1. Implement the UnsortedList cl.pdf
Using the C++ programming language1. Implement the UnsortedList cl.pdfUsing the C++ programming language1. Implement the UnsortedList cl.pdf
Using the C++ programming language1. Implement the UnsortedList cl.pdf
 
To complete the task, you need to fill in the missing code. I’ve inc.pdf
To complete the task, you need to fill in the missing code. I’ve inc.pdfTo complete the task, you need to fill in the missing code. I’ve inc.pdf
To complete the task, you need to fill in the missing code. I’ve inc.pdf
 
Unit7 C
Unit7 CUnit7 C
Unit7 C
 
implement the ListLinked ADT (the declaration is given in ListLinked.pdf
implement the ListLinked ADT (the declaration is given in ListLinked.pdfimplement the ListLinked ADT (the declaration is given in ListLinked.pdf
implement the ListLinked ADT (the declaration is given in ListLinked.pdf
 
Adt of lists
Adt of listsAdt of lists
Adt of lists
 
Write a C++ function that delete nodes in a doubly linkedlist- It shou.docx
Write a C++ function that delete nodes in a doubly linkedlist- It shou.docxWrite a C++ function that delete nodes in a doubly linkedlist- It shou.docx
Write a C++ function that delete nodes in a doubly linkedlist- It shou.docx
 
Write a program that accepts an arithmetic expression of unsigned in.pdf
Write a program that accepts an arithmetic expression of unsigned in.pdfWrite a program that accepts an arithmetic expression of unsigned in.pdf
Write a program that accepts an arithmetic expression of unsigned in.pdf
 
Below is a depiction of a doubly-linked list implementation of the bag.docx
Below is a depiction of a doubly-linked list implementation of the bag.docxBelow is a depiction of a doubly-linked list implementation of the bag.docx
Below is a depiction of a doubly-linked list implementation of the bag.docx
 
How do you stop infinite loop Because I believe that it is making a.pdf
How do you stop infinite loop Because I believe that it is making a.pdfHow do you stop infinite loop Because I believe that it is making a.pdf
How do you stop infinite loop Because I believe that it is making a.pdf
 

More from nitinarora01

Describe the movement of yeast cells once ingested by a paramecium &.pdf
Describe the movement of yeast cells once ingested by a paramecium &.pdfDescribe the movement of yeast cells once ingested by a paramecium &.pdf
Describe the movement of yeast cells once ingested by a paramecium &.pdf
nitinarora01
 
Chapter 2 problems.1.            (Problem 1) Of the following, whi.pdf
Chapter 2 problems.1.            (Problem 1) Of the following, whi.pdfChapter 2 problems.1.            (Problem 1) Of the following, whi.pdf
Chapter 2 problems.1.            (Problem 1) Of the following, whi.pdf
nitinarora01
 
By equity . Party A owns a factory that emits large quantities of f.pdf
By equity . Party A owns a factory that emits large quantities of f.pdfBy equity . Party A owns a factory that emits large quantities of f.pdf
By equity . Party A owns a factory that emits large quantities of f.pdf
nitinarora01
 
An Overview of Transport Mechanisms In Plants. Relate the structure .pdf
An Overview of Transport Mechanisms In Plants.  Relate the structure .pdfAn Overview of Transport Mechanisms In Plants.  Relate the structure .pdf
An Overview of Transport Mechanisms In Plants. Relate the structure .pdf
nitinarora01
 
amazon.com & pinterest.com -- Web 2.0 ApplicationsAddress how eac.pdf
amazon.com & pinterest.com -- Web 2.0 ApplicationsAddress how eac.pdfamazon.com & pinterest.com -- Web 2.0 ApplicationsAddress how eac.pdf
amazon.com & pinterest.com -- Web 2.0 ApplicationsAddress how eac.pdf
nitinarora01
 
All organelles (check all that apply) Are membrane bound Contain th.pdf
All organelles (check all that apply)  Are membrane bound  Contain th.pdfAll organelles (check all that apply)  Are membrane bound  Contain th.pdf
All organelles (check all that apply) Are membrane bound Contain th.pdf
nitinarora01
 
A study designed to evaluate the effect of the herbal remedy Echinac.pdf
A study designed to evaluate the effect of the herbal remedy Echinac.pdfA study designed to evaluate the effect of the herbal remedy Echinac.pdf
A study designed to evaluate the effect of the herbal remedy Echinac.pdf
nitinarora01
 
37. If the material below the sandstone of problem 26 is a shale with.pdf
37. If the material below the sandstone of problem 26 is a shale with.pdf37. If the material below the sandstone of problem 26 is a shale with.pdf
37. If the material below the sandstone of problem 26 is a shale with.pdf
nitinarora01
 
Why didnt implementation of robots in the 1980s continue to increas.pdf
Why didnt implementation of robots in the 1980s continue to increas.pdfWhy didnt implementation of robots in the 1980s continue to increas.pdf
Why didnt implementation of robots in the 1980s continue to increas.pdf
nitinarora01
 
Which property of life (e.g. homeostasis) is illustrated by each of .pdf
Which property of life (e.g. homeostasis) is illustrated by each of .pdfWhich property of life (e.g. homeostasis) is illustrated by each of .pdf
Which property of life (e.g. homeostasis) is illustrated by each of .pdf
nitinarora01
 
Which of the following statements is FALSE regarding microbial mats.pdf
Which of the following statements is FALSE regarding microbial mats.pdfWhich of the following statements is FALSE regarding microbial mats.pdf
Which of the following statements is FALSE regarding microbial mats.pdf
nitinarora01
 
What roles do membranes play in a cellWhat are cell membranes com.pdf
What roles do membranes play in a cellWhat are cell membranes com.pdfWhat roles do membranes play in a cellWhat are cell membranes com.pdf
What roles do membranes play in a cellWhat are cell membranes com.pdf
nitinarora01
 
26. The gecko is a reptile that has the amazing ability to climb smo.pdf
26. The gecko is a reptile that has the amazing ability to climb smo.pdf26. The gecko is a reptile that has the amazing ability to climb smo.pdf
26. The gecko is a reptile that has the amazing ability to climb smo.pdf
nitinarora01
 
What is soft trend vs. hard trend Analyze a specific software engin.pdf
What is soft trend vs. hard trend Analyze a specific software engin.pdfWhat is soft trend vs. hard trend Analyze a specific software engin.pdf
What is soft trend vs. hard trend Analyze a specific software engin.pdf
nitinarora01
 
what does it mean to be a social scientistSolutionSocial .pdf
what does it mean to be a social scientistSolutionSocial .pdfwhat does it mean to be a social scientistSolutionSocial .pdf
what does it mean to be a social scientistSolutionSocial .pdf
nitinarora01
 
What are the advantages for proteins to form three-dimensional struc.pdf
What are the advantages for proteins to form three-dimensional struc.pdfWhat are the advantages for proteins to form three-dimensional struc.pdf
What are the advantages for proteins to form three-dimensional struc.pdf
nitinarora01
 
Weather List the types of materials used to create a concrete sidewal.pdf
Weather List the types of materials used to create a concrete sidewal.pdfWeather List the types of materials used to create a concrete sidewal.pdf
Weather List the types of materials used to create a concrete sidewal.pdf
nitinarora01
 
The OSI Reference Model layers, in order from top to bottom, areA.pdf
The OSI Reference Model layers, in order from top to bottom, areA.pdfThe OSI Reference Model layers, in order from top to bottom, areA.pdf
The OSI Reference Model layers, in order from top to bottom, areA.pdf
nitinarora01
 
Question 1 (1 point)Tjhe pH of blood is __________ and when the .pdf
Question 1 (1 point)Tjhe pH of blood is __________ and when the .pdfQuestion 1 (1 point)Tjhe pH of blood is __________ and when the .pdf
Question 1 (1 point)Tjhe pH of blood is __________ and when the .pdf
nitinarora01
 
Q1)What kind of chemical bonds determine the properties of polyethyl.pdf
Q1)What kind of chemical bonds determine the properties of polyethyl.pdfQ1)What kind of chemical bonds determine the properties of polyethyl.pdf
Q1)What kind of chemical bonds determine the properties of polyethyl.pdf
nitinarora01
 

More from nitinarora01 (20)

Describe the movement of yeast cells once ingested by a paramecium &.pdf
Describe the movement of yeast cells once ingested by a paramecium &.pdfDescribe the movement of yeast cells once ingested by a paramecium &.pdf
Describe the movement of yeast cells once ingested by a paramecium &.pdf
 
Chapter 2 problems.1.            (Problem 1) Of the following, whi.pdf
Chapter 2 problems.1.            (Problem 1) Of the following, whi.pdfChapter 2 problems.1.            (Problem 1) Of the following, whi.pdf
Chapter 2 problems.1.            (Problem 1) Of the following, whi.pdf
 
By equity . Party A owns a factory that emits large quantities of f.pdf
By equity . Party A owns a factory that emits large quantities of f.pdfBy equity . Party A owns a factory that emits large quantities of f.pdf
By equity . Party A owns a factory that emits large quantities of f.pdf
 
An Overview of Transport Mechanisms In Plants. Relate the structure .pdf
An Overview of Transport Mechanisms In Plants.  Relate the structure .pdfAn Overview of Transport Mechanisms In Plants.  Relate the structure .pdf
An Overview of Transport Mechanisms In Plants. Relate the structure .pdf
 
amazon.com & pinterest.com -- Web 2.0 ApplicationsAddress how eac.pdf
amazon.com & pinterest.com -- Web 2.0 ApplicationsAddress how eac.pdfamazon.com & pinterest.com -- Web 2.0 ApplicationsAddress how eac.pdf
amazon.com & pinterest.com -- Web 2.0 ApplicationsAddress how eac.pdf
 
All organelles (check all that apply) Are membrane bound Contain th.pdf
All organelles (check all that apply)  Are membrane bound  Contain th.pdfAll organelles (check all that apply)  Are membrane bound  Contain th.pdf
All organelles (check all that apply) Are membrane bound Contain th.pdf
 
A study designed to evaluate the effect of the herbal remedy Echinac.pdf
A study designed to evaluate the effect of the herbal remedy Echinac.pdfA study designed to evaluate the effect of the herbal remedy Echinac.pdf
A study designed to evaluate the effect of the herbal remedy Echinac.pdf
 
37. If the material below the sandstone of problem 26 is a shale with.pdf
37. If the material below the sandstone of problem 26 is a shale with.pdf37. If the material below the sandstone of problem 26 is a shale with.pdf
37. If the material below the sandstone of problem 26 is a shale with.pdf
 
Why didnt implementation of robots in the 1980s continue to increas.pdf
Why didnt implementation of robots in the 1980s continue to increas.pdfWhy didnt implementation of robots in the 1980s continue to increas.pdf
Why didnt implementation of robots in the 1980s continue to increas.pdf
 
Which property of life (e.g. homeostasis) is illustrated by each of .pdf
Which property of life (e.g. homeostasis) is illustrated by each of .pdfWhich property of life (e.g. homeostasis) is illustrated by each of .pdf
Which property of life (e.g. homeostasis) is illustrated by each of .pdf
 
Which of the following statements is FALSE regarding microbial mats.pdf
Which of the following statements is FALSE regarding microbial mats.pdfWhich of the following statements is FALSE regarding microbial mats.pdf
Which of the following statements is FALSE regarding microbial mats.pdf
 
What roles do membranes play in a cellWhat are cell membranes com.pdf
What roles do membranes play in a cellWhat are cell membranes com.pdfWhat roles do membranes play in a cellWhat are cell membranes com.pdf
What roles do membranes play in a cellWhat are cell membranes com.pdf
 
26. The gecko is a reptile that has the amazing ability to climb smo.pdf
26. The gecko is a reptile that has the amazing ability to climb smo.pdf26. The gecko is a reptile that has the amazing ability to climb smo.pdf
26. The gecko is a reptile that has the amazing ability to climb smo.pdf
 
What is soft trend vs. hard trend Analyze a specific software engin.pdf
What is soft trend vs. hard trend Analyze a specific software engin.pdfWhat is soft trend vs. hard trend Analyze a specific software engin.pdf
What is soft trend vs. hard trend Analyze a specific software engin.pdf
 
what does it mean to be a social scientistSolutionSocial .pdf
what does it mean to be a social scientistSolutionSocial .pdfwhat does it mean to be a social scientistSolutionSocial .pdf
what does it mean to be a social scientistSolutionSocial .pdf
 
What are the advantages for proteins to form three-dimensional struc.pdf
What are the advantages for proteins to form three-dimensional struc.pdfWhat are the advantages for proteins to form three-dimensional struc.pdf
What are the advantages for proteins to form three-dimensional struc.pdf
 
Weather List the types of materials used to create a concrete sidewal.pdf
Weather List the types of materials used to create a concrete sidewal.pdfWeather List the types of materials used to create a concrete sidewal.pdf
Weather List the types of materials used to create a concrete sidewal.pdf
 
The OSI Reference Model layers, in order from top to bottom, areA.pdf
The OSI Reference Model layers, in order from top to bottom, areA.pdfThe OSI Reference Model layers, in order from top to bottom, areA.pdf
The OSI Reference Model layers, in order from top to bottom, areA.pdf
 
Question 1 (1 point)Tjhe pH of blood is __________ and when the .pdf
Question 1 (1 point)Tjhe pH of blood is __________ and when the .pdfQuestion 1 (1 point)Tjhe pH of blood is __________ and when the .pdf
Question 1 (1 point)Tjhe pH of blood is __________ and when the .pdf
 
Q1)What kind of chemical bonds determine the properties of polyethyl.pdf
Q1)What kind of chemical bonds determine the properties of polyethyl.pdfQ1)What kind of chemical bonds determine the properties of polyethyl.pdf
Q1)What kind of chemical bonds determine the properties of polyethyl.pdf
 

Recently uploaded

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
Balvir Singh
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
Basic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumersBasic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumers
PedroFerreira53928
 
How to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERPHow to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERP
Celine George
 
Sectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdfSectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdf
Vivekanand Anglo Vedic Academy
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
Sandy Millin
 
Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
Atul Kumar Singh
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
Celine George
 
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
Nguyen Thanh Tu Collection
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
beazzy04
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
GeoBlogs
 
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
AzmatAli747758
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
joachimlavalley1
 
PART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePART A. Introduction to Costumer Service
PART A. Introduction to Costumer Service
PedroFerreira53928
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
kaushalkr1407
 

Recently uploaded (20)

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
Basic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumersBasic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumers
 
How to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERPHow to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERP
 
Sectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdfSectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdf
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
 
Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
 
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
 
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
 
PART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePART A. Introduction to Costumer Service
PART A. Introduction to Costumer Service
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
 

Please need help on following program using c++ language. Please inc.pdf

  • 1. Please need help on following program using c++ language. Please include all header files and main file with their own title. Extend the class linkedListType by adding the following operations: Write a function that returns the info of the kth element of the linked list. If no such element exists, terminate the program. Write a function that deletes the kth element of the linked list. If no such element exists, terminate the program. Provide the definitions of these functions in the class linkedListType. Also, write a program to test these functions. (Use either the class unorderedLinkedList or the class orderedLinkedList to test your function.) Solution C++ Code for the given problem is below..... ..................................................... /* * C++ Program to Implement Singly Linked List */ #include #include #include //using namespace std; /* * Node Declaration */ typedef struct nodetype { int info; nodetype *next ; } node; /* * Class Declaration */ class linkedListType
  • 2. { public: void insfrombeg( node **head, int); void delfromkth(node **head,int); void findthekthnode(node *head,int); void traverse(node *head); int item,ch,kth; node *ptr,*head,*temp; }; /* * Main :contains menu */ void main() { int item,ch,kth; node *ptr,*head,*temp; linkedListType s1; clrscr(); while (1) { while(1) { cout<<"PRESS (1) FOR INSERT INTO LIST"<>ch; switch(ch) { case 1: cout<<"ENTER THE VALUE "<>item; s1.insfrombeg(&head,item); break; case 2: s1.traverse(head); break; case 3: cout<<"ENTER THE Kth Element which you want's to delete"<>kth; s1.delfromkth(&head,kth); break;
  • 3. case 4: cout<<"ENTER THE Kth Element which you want's to search "<>kth; s1.findthekthnode(head,kth); break; case 5: exit(1); } } // getch(); } } /* * Inserting element in beginning */ void linkedListType::insfrombeg(node **head,int item) { temp= ( node * ) malloc (sizeof( node )); temp->info= item; temp->next= NULL; if(*head == NULL) { temp->next= *head; *head= temp; } else { temp->next= *head; *head= temp; } } /* * Delete element at a given position */ void linkedListType::delfromkth(node **head,int kth)
  • 4. { node* temp1=*head,*temp2; if(*head ==NULL) { cout<<"LINK LIST IS EMPTY "<next; free(temp); } else for(int j=0;jnext; temp2= temp1->next; temp1->next=temp2->next; free(temp2); } /* * Searching an element */ void linkedListType::findthekthnode(node *head,int kth) { ptr=head; int i=1; while((ptr!=NULL)) { if(i==kth) { cout<<" The Element at"<< kth<< "position with value is t "<info<info<next; i++; } } } /* * Traverse Link List */ void linkedListType::traverse(node *head)
  • 5. { ptr = head; while((ptr->next)->next!=NULL) { cout<info<<"t"; ptr=ptr->next; } cout< #include #include typedef struct nodetype { int info; nodetype *next ; } node; int item,ch,kth,total=1; node *ptr,*head,*temp; void insfrombeg( node **head, int); void delfromkth(node **head,int); void findthekthnode(node *head,int); void traverse(node *head); void main() { clrscr(); while(1) { printf("PRESS (1) FOR INSERT INTO LIST "); printf("PRESS (2) FOR TRAVERSE FROM INORDER "); printf("PRESS (3) FOR DELETE FROM kth NODE " ); printf("PRESS (4) FOR FIND THE Kth NODE " ); printf("PRESS (5) FOR EXIT FROM MENU "); printf("ENTER YOUR CHOICE "); scanf("%d",&ch); switch(ch) { case 1:
  • 6. printf("ENTER THE VALUE ") ; scanf("%d",&item); insfrombeg(&head,item); break; case 2: traverse(head); break; case 3: printf("ENTER THE Kth Element which you want's to delete ") ; scanf("%d",&kth); delfromkth(&head,kth); break; case 4: printf("ENTER THE Kth Element which you want's to search "); scanf("%d",&kth); findthekthnode(head,kth); break; case 5: exit(1); } } // getch(); } void insfrombeg(node **head,int item) { temp= ( node * ) malloc (sizeof( node )); temp->info= item; temp->next= NULL; if(*head == NULL) { temp->next= *head; *head= temp; } else { temp->next= *head;
  • 7. *head= temp; } } void findthekthnode(node *head,int kth) { ptr=head; int i=1; while((ptr!=NULL)) { if(i==kth) { printf(" The Element at %d position with value is %dt",kth,ptr->info); printf(" "); break; } else { printf("%dt",ptr->info); ptr=ptr->next; i++; } } } void delfromkth(node **head,int kth) { node* temp1=*head,*temp2; if(*head ==NULL) { printf("LINK LIST IS EMPTY "); exit; } if(kth==1) { *head= temp1->next; free(temp); } else for(int j=0;jnext;
  • 8. temp2= temp1->next; temp1->next=temp2->next; free(temp2); } void traverse(node *head) { ptr = head; while(ptr!=NULL) { printf("%dt",ptr->info); ptr=ptr->next; } printf(" "); }