SlideShare a Scribd company logo
1 of 8
Download to read offline
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.pdfankit11134
 
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.pdfpoblettesedanoree498
 
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.pdfrozakashif85
 
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.pdffcaindore
 
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.docxteyaj1
 
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.pdfjyothimuppasani1
 
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.pdfudit652068
 
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 .pdfarihantstoneart
 
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.pdfaminbijal86
 
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.pdfmallik3000
 
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.pdfezycolours78
 
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.pdfFOREVERPRODUCTCHD
 
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.docxnoreendchesterton753
 
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.pdfJUSTSTYLISH3B2MOHALI
 
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.docxgilliandunce53776
 
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.pdffeelinggift
 

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 &.pdfnitinarora01
 
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.pdfnitinarora01
 
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.pdfnitinarora01
 
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 .pdfnitinarora01
 
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.pdfnitinarora01
 
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.pdfnitinarora01
 
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.pdfnitinarora01
 
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.pdfnitinarora01
 
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.pdfnitinarora01
 
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 .pdfnitinarora01
 
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.pdfnitinarora01
 
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.pdfnitinarora01
 
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.pdfnitinarora01
 
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.pdfnitinarora01
 
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 .pdfnitinarora01
 
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.pdfnitinarora01
 
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.pdfnitinarora01
 
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.pdfnitinarora01
 
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 .pdfnitinarora01
 
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.pdfnitinarora01
 

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

BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 

Recently uploaded (20)

BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 

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(" "); }