SlideShare a Scribd company logo
Programming Linked List
class LinkedList{
// declaration of the node
struct node{
int info;
node *next;
};
//private variable declared
node *start;
public:
LinkedList() //
Constructor
{
start = NULL;
}
//public fucntion declared
void AddAtBeg(int);
void AddAfter(int, int);
void Delete();
void Count();
void Search(int);
void Display();
};
20
Programming Linked List
// following function will add new element at the beginning
// also used to create first node
void LinkedList::AddAtBeg(int data)
{
node * newNode;
newNode = new node;
newNode->info = data;
newNode->next = start;
start = newNode;
}/*End of addatbeg()*/
21
Programming Linked List
//This function will add new element at any position
void LinkedList::AddAfter(int data, int pos)
{ node *newNode, *q;
q = start;
if(q == NULL) {
cout<<"nnEmpty linked list" << endl;
return;
}
//Finding the position in the linked list to insert
for(int i = 1; i < pos; i++)
q = q->next;
newNode = new node;
newNode->info = data;
newNode->next = q->next;
q->next = newNode;
}
22
Programming Linked List
void LinkedList::Delete()
{
node *tmp, *ptr;
int data;
if(start == NULL)
{
cout<<"nn List is empty"<<endl;
return;
}
cout<<"nnEnter the element for deletion : ";
cin>>data; // delete first node
if(start->info == data)
{ tmp = start;
start = start->next;
delete(tmp);
return;
}
23
ptr = start;
while(ptr->info != data) {
temp = ptr;
ptr = ptr ->next;
}
tmp->next = ptr->next;
delete(ptr); // Delete node in between, or last
node
}/*End of del()*/
24
Programming Linked List
void LinkedList::Display()
{
// Fill in the code that displays the contents of the linked list
} /*End of display() */
void LinkedList::Count()
{
// Fill in the code
that counts the
nodes of the linked
list
} /*End of count() */
void LinkedList::Search(int data)
{
// Fill in the code that will find the position of a node that
holds the ‘data’
} 25
Programming Linked List
int main()
{
int choice, n, m, position, i;
LinkedList po;
while(1)
{
cout<<"1. Add at beginningn";
cout<<"2. Add after n";
cout<<"3. Deleten";
cout<<"4. Displayn";
cout<<"5. Countn";
26
Programming Linked List
cout<<"6. Searchn"
cout<<"7. Quitn";
cout<<"n Enter your choice:";
cin>> choice;
switch(choice) {
case 1:
cout<<"nnEnter the element:";
cin>>m;
po.AddAtBeg(m);
break;
27
Programming Linked List
case 2:
cout<<"nnEnter the element:";
cin>>m;
cout<<"nPosition after inserted element:";
cin>>position;
po.AddAfter(m,position);
break;
case 3: po.Delete();
break;
case 4: po.Display();
break;
case 5: po.Count();
break;
case 6: cout<<"n
nEnter the element
to search:"; 28
Programming Linked List
cin>>m;
po.Search(m);
break;
case 7:
exit(0);
default:
c
out<<"
n
nWron
g
choice
";
}/*End of
switch */
29
Ad

More Related Content

Similar to Link List Programming Linked List in Cpp (20)

linked List.docx vhjgvjhvgjhjhbbjkhkjhkjh
linked List.docx vhjgvjhvgjhjhbbjkhkjhkjhlinked List.docx vhjgvjhvgjhjhbbjkhkjhkjh
linked List.docx vhjgvjhvgjhjhbbjkhkjhkjh
vasavim9
 
Write a program to implement below operations with both singly and d.pdf
Write a program to implement below operations with both singly and d.pdfWrite a program to implement below operations with both singly and d.pdf
Write a program to implement below operations with both singly and d.pdf
thangarajarivukadal
 
THE CODE HAS A SEGMENTATION FAULT BUT I CANNOT FIND OUT WHERE. NEED .pdf
THE CODE HAS A SEGMENTATION FAULT BUT I CANNOT FIND OUT WHERE. NEED .pdfTHE CODE HAS A SEGMENTATION FAULT BUT I CANNOT FIND OUT WHERE. NEED .pdf
THE CODE HAS A SEGMENTATION FAULT BUT I CANNOT FIND OUT WHERE. NEED .pdf
fathimahardwareelect
 
mainpublic class AssignmentThree {    public static void ma.pdf
mainpublic class AssignmentThree {    public static void ma.pdfmainpublic class AssignmentThree {    public static void ma.pdf
mainpublic class AssignmentThree {    public static void ma.pdf
fathimafancyjeweller
 
DS UNIT4_OTHER LIST STRUCTURES.docx
DS UNIT4_OTHER LIST STRUCTURES.docxDS UNIT4_OTHER LIST STRUCTURES.docx
DS UNIT4_OTHER LIST STRUCTURES.docx
VeerannaKotagi1
 
hi i have to write a java program involving link lists. i have a pro.pdf
hi i have to write a java program involving link lists. i have a pro.pdfhi i have to write a java program involving link lists. i have a pro.pdf
hi i have to write a java program involving link lists. i have a pro.pdf
archgeetsenterprises
 
C++ Please write the whole code that is needed for this assignment- wr.docx
C++ Please write the whole code that is needed for this assignment- wr.docxC++ Please write the whole code that is needed for this assignment- wr.docx
C++ Please write the whole code that is needed for this assignment- wr.docx
BrianGHiNewmanv
 
Assignment is Page 349-350 #4 and #5 Use the Linked Lis.pdf
Assignment is Page 349-350 #4 and #5 Use the Linked Lis.pdfAssignment is Page 349-350 #4 and #5 Use the Linked Lis.pdf
Assignment is Page 349-350 #4 and #5 Use the Linked Lis.pdf
formicreation
 
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
 
TutorialII_Updated____niceupdateprogram.pdf
TutorialII_Updated____niceupdateprogram.pdfTutorialII_Updated____niceupdateprogram.pdf
TutorialII_Updated____niceupdateprogram.pdf
BappyAgarwal
 
C code on linked list #include stdio.h #include stdlib.h.pdf
 C code on linked list #include stdio.h #include stdlib.h.pdf C code on linked list #include stdio.h #include stdlib.h.pdf
C code on linked list #include stdio.h #include stdlib.h.pdf
deepua8
 
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
 
could you implement this function please, im having issues with it..pdf
could you implement this function please, im having issues with it..pdfcould you implement this function please, im having issues with it..pdf
could you implement this function please, im having issues with it..pdf
feroz544
 
Inspect the class declaration for a doubly-linked list node in Node-h-.pdf
Inspect the class declaration for a doubly-linked list node in Node-h-.pdfInspect the class declaration for a doubly-linked list node in Node-h-.pdf
Inspect the class declaration for a doubly-linked list node in Node-h-.pdf
vishalateen
 
PROBLEM STATEMENTIn this assignment, you will complete DoubleEnde.pdf
PROBLEM STATEMENTIn this assignment, you will complete DoubleEnde.pdfPROBLEM STATEMENTIn this assignment, you will complete DoubleEnde.pdf
PROBLEM STATEMENTIn this assignment, you will complete DoubleEnde.pdf
climatecontrolsv
 
Assignment isPage 349-350 #4 and #5 Use the Linked List lab.pdf
Assignment isPage 349-350 #4 and #5 Use the Linked List lab.pdfAssignment isPage 349-350 #4 and #5 Use the Linked List lab.pdf
Assignment isPage 349-350 #4 and #5 Use the Linked List lab.pdf
fortmdu
 
A)B) C++ program to create a Complete Binary tree from its Lin.pdf
A)B) C++ program to create a Complete Binary tree from its Lin.pdfA)B) C++ program to create a Complete Binary tree from its Lin.pdf
A)B) C++ program to create a Complete Binary tree from its Lin.pdf
anton291
 
I need help completing this C++ code with these requirements.instr.pdf
I need help completing this C++ code with these requirements.instr.pdfI need help completing this C++ code with these requirements.instr.pdf
I need help completing this C++ code with these requirements.instr.pdf
eyeonsecuritysystems
 
Consider a double-linked linked list implementation with the followin.pdf
Consider a double-linked linked list implementation with the followin.pdfConsider a double-linked linked list implementation with the followin.pdf
Consider a double-linked linked list implementation with the followin.pdf
sales98
 
The LinkedList1 class implements a Linked list. class.pdf
The LinkedList1 class implements a Linked list. class.pdfThe LinkedList1 class implements a Linked list. class.pdf
The LinkedList1 class implements a Linked list. class.pdf
malavshah9013
 
linked List.docx vhjgvjhvgjhjhbbjkhkjhkjh
linked List.docx vhjgvjhvgjhjhbbjkhkjhkjhlinked List.docx vhjgvjhvgjhjhbbjkhkjhkjh
linked List.docx vhjgvjhvgjhjhbbjkhkjhkjh
vasavim9
 
Write a program to implement below operations with both singly and d.pdf
Write a program to implement below operations with both singly and d.pdfWrite a program to implement below operations with both singly and d.pdf
Write a program to implement below operations with both singly and d.pdf
thangarajarivukadal
 
THE CODE HAS A SEGMENTATION FAULT BUT I CANNOT FIND OUT WHERE. NEED .pdf
THE CODE HAS A SEGMENTATION FAULT BUT I CANNOT FIND OUT WHERE. NEED .pdfTHE CODE HAS A SEGMENTATION FAULT BUT I CANNOT FIND OUT WHERE. NEED .pdf
THE CODE HAS A SEGMENTATION FAULT BUT I CANNOT FIND OUT WHERE. NEED .pdf
fathimahardwareelect
 
mainpublic class AssignmentThree {    public static void ma.pdf
mainpublic class AssignmentThree {    public static void ma.pdfmainpublic class AssignmentThree {    public static void ma.pdf
mainpublic class AssignmentThree {    public static void ma.pdf
fathimafancyjeweller
 
DS UNIT4_OTHER LIST STRUCTURES.docx
DS UNIT4_OTHER LIST STRUCTURES.docxDS UNIT4_OTHER LIST STRUCTURES.docx
DS UNIT4_OTHER LIST STRUCTURES.docx
VeerannaKotagi1
 
hi i have to write a java program involving link lists. i have a pro.pdf
hi i have to write a java program involving link lists. i have a pro.pdfhi i have to write a java program involving link lists. i have a pro.pdf
hi i have to write a java program involving link lists. i have a pro.pdf
archgeetsenterprises
 
C++ Please write the whole code that is needed for this assignment- wr.docx
C++ Please write the whole code that is needed for this assignment- wr.docxC++ Please write the whole code that is needed for this assignment- wr.docx
C++ Please write the whole code that is needed for this assignment- wr.docx
BrianGHiNewmanv
 
Assignment is Page 349-350 #4 and #5 Use the Linked Lis.pdf
Assignment is Page 349-350 #4 and #5 Use the Linked Lis.pdfAssignment is Page 349-350 #4 and #5 Use the Linked Lis.pdf
Assignment is Page 349-350 #4 and #5 Use the Linked Lis.pdf
formicreation
 
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
 
TutorialII_Updated____niceupdateprogram.pdf
TutorialII_Updated____niceupdateprogram.pdfTutorialII_Updated____niceupdateprogram.pdf
TutorialII_Updated____niceupdateprogram.pdf
BappyAgarwal
 
C code on linked list #include stdio.h #include stdlib.h.pdf
 C code on linked list #include stdio.h #include stdlib.h.pdf C code on linked list #include stdio.h #include stdlib.h.pdf
C code on linked list #include stdio.h #include stdlib.h.pdf
deepua8
 
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
 
could you implement this function please, im having issues with it..pdf
could you implement this function please, im having issues with it..pdfcould you implement this function please, im having issues with it..pdf
could you implement this function please, im having issues with it..pdf
feroz544
 
Inspect the class declaration for a doubly-linked list node in Node-h-.pdf
Inspect the class declaration for a doubly-linked list node in Node-h-.pdfInspect the class declaration for a doubly-linked list node in Node-h-.pdf
Inspect the class declaration for a doubly-linked list node in Node-h-.pdf
vishalateen
 
PROBLEM STATEMENTIn this assignment, you will complete DoubleEnde.pdf
PROBLEM STATEMENTIn this assignment, you will complete DoubleEnde.pdfPROBLEM STATEMENTIn this assignment, you will complete DoubleEnde.pdf
PROBLEM STATEMENTIn this assignment, you will complete DoubleEnde.pdf
climatecontrolsv
 
Assignment isPage 349-350 #4 and #5 Use the Linked List lab.pdf
Assignment isPage 349-350 #4 and #5 Use the Linked List lab.pdfAssignment isPage 349-350 #4 and #5 Use the Linked List lab.pdf
Assignment isPage 349-350 #4 and #5 Use the Linked List lab.pdf
fortmdu
 
A)B) C++ program to create a Complete Binary tree from its Lin.pdf
A)B) C++ program to create a Complete Binary tree from its Lin.pdfA)B) C++ program to create a Complete Binary tree from its Lin.pdf
A)B) C++ program to create a Complete Binary tree from its Lin.pdf
anton291
 
I need help completing this C++ code with these requirements.instr.pdf
I need help completing this C++ code with these requirements.instr.pdfI need help completing this C++ code with these requirements.instr.pdf
I need help completing this C++ code with these requirements.instr.pdf
eyeonsecuritysystems
 
Consider a double-linked linked list implementation with the followin.pdf
Consider a double-linked linked list implementation with the followin.pdfConsider a double-linked linked list implementation with the followin.pdf
Consider a double-linked linked list implementation with the followin.pdf
sales98
 
The LinkedList1 class implements a Linked list. class.pdf
The LinkedList1 class implements a Linked list. class.pdfThe LinkedList1 class implements a Linked list. class.pdf
The LinkedList1 class implements a Linked list. class.pdf
malavshah9013
 

More from Anil Yadav (20)

Link List : Introduction to List and Linked Lists
Link List : Introduction to List and Linked ListsLink List : Introduction to List and Linked Lists
Link List : Introduction to List and Linked Lists
Anil Yadav
 
Link List REPRESENTATION OF DOUBLY LINKED LIST
Link List REPRESENTATION OF DOUBLY LINKED LISTLink List REPRESENTATION OF DOUBLY LINKED LIST
Link List REPRESENTATION OF DOUBLY LINKED LIST
Anil Yadav
 
ALGORITHM FOR PUSHING AN ELEMENT TO A QUEUE
ALGORITHM FOR PUSHING AN ELEMENT TO A QUEUEALGORITHM FOR PUSHING AN ELEMENT TO A QUEUE
ALGORITHM FOR PUSHING AN ELEMENT TO A QUEUE
Anil Yadav
 
Link List STACK and Queue USING LINKED LIST
Link List STACK and Queue USING LINKED LISTLink List STACK and Queue USING LINKED LIST
Link List STACK and Queue USING LINKED LIST
Anil Yadav
 
Link List & ALGORITHM FOR DELETING A NODE
Link List & ALGORITHM FOR DELETING A NODELink List & ALGORITHM FOR DELETING A NODE
Link List & ALGORITHM FOR DELETING A NODE
Anil Yadav
 
Link List ALGORITHM FOR INSERTING A NODE
Link List ALGORITHM FOR INSERTING A NODELink List ALGORITHM FOR INSERTING A NODE
Link List ALGORITHM FOR INSERTING A NODE
Anil Yadav
 
Presentations Linked Lists Data Structure
Presentations Linked Lists Data StructurePresentations Linked Lists Data Structure
Presentations Linked Lists Data Structure
Anil Yadav
 
Lec-12, 13 Quees First In First Out (FIFO)
Lec-12, 13 Quees First In First Out (FIFO)Lec-12, 13 Quees First In First Out (FIFO)
Lec-12, 13 Quees First In First Out (FIFO)
Anil Yadav
 
Lec-12, 13 Quee s Applications of Queues
Lec-12, 13 Quee s Applications of QueuesLec-12, 13 Quee s Applications of Queues
Lec-12, 13 Quee s Applications of Queues
Anil Yadav
 
Lec-12, 13 Quees Array Implementation IN
Lec-12, 13 Quees Array Implementation INLec-12, 13 Quees Array Implementation IN
Lec-12, 13 Quees Array Implementation IN
Anil Yadav
 
Lec-12, 13 Quees In Queue IntQueue(int s)
Lec-12, 13 Quees In Queue IntQueue(int s)Lec-12, 13 Quees In Queue IntQueue(int s)
Lec-12, 13 Quees In Queue IntQueue(int s)
Anil Yadav
 
Lec-12, 13 Quees A class for Dynamic Queue implementation
Lec-12, 13 Quees A class for Dynamic Queue implementationLec-12, 13 Quees A class for Dynamic Queue implementation
Lec-12, 13 Quees A class for Dynamic Queue implementation
Anil Yadav
 
Function enqueue inserts the value in num
Function enqueue inserts the value in numFunction enqueue inserts the value in num
Function enqueue inserts the value in num
Anil Yadav
 
Lec-12, 13 Quees -How to determine empty and full Queues?
Lec-12, 13 Quees -How to determine empty and full Queues?Lec-12, 13 Quees -How to determine empty and full Queues?
Lec-12, 13 Quees -How to determine empty and full Queues?
Anil Yadav
 
Unit2-BIS Business Information system Data
Unit2-BIS Business Information system DataUnit2-BIS Business Information system Data
Unit2-BIS Business Information system Data
Anil Yadav
 
Lec-12, 13 Queues - IntQueue IntQueue(int s) //constructor
Lec-12, 13 Queues - IntQueue IntQueue(int s) //constructorLec-12, 13 Queues - IntQueue IntQueue(int s) //constructor
Lec-12, 13 Queues - IntQueue IntQueue(int s) //constructor
Anil Yadav
 
Lec-12, 13 Quees Another implementation of Queues using Arrays
Lec-12, 13 Quees Another implementation of Queues using ArraysLec-12, 13 Quees Another implementation of Queues using Arrays
Lec-12, 13 Quees Another implementation of Queues using Arrays
Anil Yadav
 
Lec-12, 13 Quees - Circular Queues and Implementation with Array
Lec-12, 13 Quees - Circular Queues and Implementation with ArrayLec-12, 13 Quees - Circular Queues and Implementation with Array
Lec-12, 13 Quees - Circular Queues and Implementation with Array
Anil Yadav
 
Lec-32 Recursion - Divide and Conquer in Queue
Lec-32 Recursion - Divide and Conquer in QueueLec-32 Recursion - Divide and Conquer in Queue
Lec-32 Recursion - Divide and Conquer in Queue
Anil Yadav
 
Lec-32 Recursion -Recursion in Computer Science
Lec-32 Recursion -Recursion in Computer ScienceLec-32 Recursion -Recursion in Computer Science
Lec-32 Recursion -Recursion in Computer Science
Anil Yadav
 
Link List : Introduction to List and Linked Lists
Link List : Introduction to List and Linked ListsLink List : Introduction to List and Linked Lists
Link List : Introduction to List and Linked Lists
Anil Yadav
 
Link List REPRESENTATION OF DOUBLY LINKED LIST
Link List REPRESENTATION OF DOUBLY LINKED LISTLink List REPRESENTATION OF DOUBLY LINKED LIST
Link List REPRESENTATION OF DOUBLY LINKED LIST
Anil Yadav
 
ALGORITHM FOR PUSHING AN ELEMENT TO A QUEUE
ALGORITHM FOR PUSHING AN ELEMENT TO A QUEUEALGORITHM FOR PUSHING AN ELEMENT TO A QUEUE
ALGORITHM FOR PUSHING AN ELEMENT TO A QUEUE
Anil Yadav
 
Link List STACK and Queue USING LINKED LIST
Link List STACK and Queue USING LINKED LISTLink List STACK and Queue USING LINKED LIST
Link List STACK and Queue USING LINKED LIST
Anil Yadav
 
Link List & ALGORITHM FOR DELETING A NODE
Link List & ALGORITHM FOR DELETING A NODELink List & ALGORITHM FOR DELETING A NODE
Link List & ALGORITHM FOR DELETING A NODE
Anil Yadav
 
Link List ALGORITHM FOR INSERTING A NODE
Link List ALGORITHM FOR INSERTING A NODELink List ALGORITHM FOR INSERTING A NODE
Link List ALGORITHM FOR INSERTING A NODE
Anil Yadav
 
Presentations Linked Lists Data Structure
Presentations Linked Lists Data StructurePresentations Linked Lists Data Structure
Presentations Linked Lists Data Structure
Anil Yadav
 
Lec-12, 13 Quees First In First Out (FIFO)
Lec-12, 13 Quees First In First Out (FIFO)Lec-12, 13 Quees First In First Out (FIFO)
Lec-12, 13 Quees First In First Out (FIFO)
Anil Yadav
 
Lec-12, 13 Quee s Applications of Queues
Lec-12, 13 Quee s Applications of QueuesLec-12, 13 Quee s Applications of Queues
Lec-12, 13 Quee s Applications of Queues
Anil Yadav
 
Lec-12, 13 Quees Array Implementation IN
Lec-12, 13 Quees Array Implementation INLec-12, 13 Quees Array Implementation IN
Lec-12, 13 Quees Array Implementation IN
Anil Yadav
 
Lec-12, 13 Quees In Queue IntQueue(int s)
Lec-12, 13 Quees In Queue IntQueue(int s)Lec-12, 13 Quees In Queue IntQueue(int s)
Lec-12, 13 Quees In Queue IntQueue(int s)
Anil Yadav
 
Lec-12, 13 Quees A class for Dynamic Queue implementation
Lec-12, 13 Quees A class for Dynamic Queue implementationLec-12, 13 Quees A class for Dynamic Queue implementation
Lec-12, 13 Quees A class for Dynamic Queue implementation
Anil Yadav
 
Function enqueue inserts the value in num
Function enqueue inserts the value in numFunction enqueue inserts the value in num
Function enqueue inserts the value in num
Anil Yadav
 
Lec-12, 13 Quees -How to determine empty and full Queues?
Lec-12, 13 Quees -How to determine empty and full Queues?Lec-12, 13 Quees -How to determine empty and full Queues?
Lec-12, 13 Quees -How to determine empty and full Queues?
Anil Yadav
 
Unit2-BIS Business Information system Data
Unit2-BIS Business Information system DataUnit2-BIS Business Information system Data
Unit2-BIS Business Information system Data
Anil Yadav
 
Lec-12, 13 Queues - IntQueue IntQueue(int s) //constructor
Lec-12, 13 Queues - IntQueue IntQueue(int s) //constructorLec-12, 13 Queues - IntQueue IntQueue(int s) //constructor
Lec-12, 13 Queues - IntQueue IntQueue(int s) //constructor
Anil Yadav
 
Lec-12, 13 Quees Another implementation of Queues using Arrays
Lec-12, 13 Quees Another implementation of Queues using ArraysLec-12, 13 Quees Another implementation of Queues using Arrays
Lec-12, 13 Quees Another implementation of Queues using Arrays
Anil Yadav
 
Lec-12, 13 Quees - Circular Queues and Implementation with Array
Lec-12, 13 Quees - Circular Queues and Implementation with ArrayLec-12, 13 Quees - Circular Queues and Implementation with Array
Lec-12, 13 Quees - Circular Queues and Implementation with Array
Anil Yadav
 
Lec-32 Recursion - Divide and Conquer in Queue
Lec-32 Recursion - Divide and Conquer in QueueLec-32 Recursion - Divide and Conquer in Queue
Lec-32 Recursion - Divide and Conquer in Queue
Anil Yadav
 
Lec-32 Recursion -Recursion in Computer Science
Lec-32 Recursion -Recursion in Computer ScienceLec-32 Recursion -Recursion in Computer Science
Lec-32 Recursion -Recursion in Computer Science
Anil Yadav
 
Ad

Recently uploaded (20)

pulse ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
pulse  ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulsepulse  ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
pulse ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
sushreesangita003
 
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptxSCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
Ronisha Das
 
Contact Lens:::: An Overview.pptx.: Optometry
Contact Lens:::: An Overview.pptx.: OptometryContact Lens:::: An Overview.pptx.: Optometry
Contact Lens:::: An Overview.pptx.: Optometry
MushahidRaza8
 
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - WorksheetCBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
Sritoma Majumder
 
Metamorphosis: Life's Transformative Journey
Metamorphosis: Life's Transformative JourneyMetamorphosis: Life's Transformative Journey
Metamorphosis: Life's Transformative Journey
Arshad Shaikh
 
Sugar-Sensing Mechanism in plants....pptx
Sugar-Sensing Mechanism in plants....pptxSugar-Sensing Mechanism in plants....pptx
Sugar-Sensing Mechanism in plants....pptx
Dr. Renu Jangid
 
Odoo Inventory Rules and Routes v17 - Odoo Slides
Odoo Inventory Rules and Routes v17 - Odoo SlidesOdoo Inventory Rules and Routes v17 - Odoo Slides
Odoo Inventory Rules and Routes v17 - Odoo Slides
Celine George
 
How to manage Multiple Warehouses for multiple floors in odoo point of sale
How to manage Multiple Warehouses for multiple floors in odoo point of saleHow to manage Multiple Warehouses for multiple floors in odoo point of sale
How to manage Multiple Warehouses for multiple floors in odoo point of sale
Celine George
 
2541William_McCollough_DigitalDetox.docx
2541William_McCollough_DigitalDetox.docx2541William_McCollough_DigitalDetox.docx
2541William_McCollough_DigitalDetox.docx
contactwilliamm2546
 
To study the nervous system of insect.pptx
To study the nervous system of insect.pptxTo study the nervous system of insect.pptx
To study the nervous system of insect.pptx
Arshad Shaikh
 
BỘ ĐỀ TUYỂN SINH VÀO LỚP 10 TIẾNG ANH - 25 ĐỀ THI BÁM SÁT CẤU TRÚC MỚI NHẤT, ...
BỘ ĐỀ TUYỂN SINH VÀO LỚP 10 TIẾNG ANH - 25 ĐỀ THI BÁM SÁT CẤU TRÚC MỚI NHẤT, ...BỘ ĐỀ TUYỂN SINH VÀO LỚP 10 TIẾNG ANH - 25 ĐỀ THI BÁM SÁT CẤU TRÚC MỚI NHẤT, ...
BỘ ĐỀ TUYỂN SINH VÀO LỚP 10 TIẾNG ANH - 25 ĐỀ THI BÁM SÁT CẤU TRÚC MỚI NHẤT, ...
Nguyen Thanh Tu Collection
 
Grade 2 - Mathematics - Printable Worksheet
Grade 2 - Mathematics - Printable WorksheetGrade 2 - Mathematics - Printable Worksheet
Grade 2 - Mathematics - Printable Worksheet
Sritoma Majumder
 
PHYSIOLOGY MCQS By DR. NASIR MUSTAFA (PHYSIOLOGY)
PHYSIOLOGY MCQS By DR. NASIR MUSTAFA (PHYSIOLOGY)PHYSIOLOGY MCQS By DR. NASIR MUSTAFA (PHYSIOLOGY)
PHYSIOLOGY MCQS By DR. NASIR MUSTAFA (PHYSIOLOGY)
Dr. Nasir Mustafa
 
Presentation of the MIPLM subject matter expert Erdem Kaya
Presentation of the MIPLM subject matter expert Erdem KayaPresentation of the MIPLM subject matter expert Erdem Kaya
Presentation of the MIPLM subject matter expert Erdem Kaya
MIPLM
 
Biophysics Chapter 3 Methods of Studying Macromolecules.pdf
Biophysics Chapter 3 Methods of Studying Macromolecules.pdfBiophysics Chapter 3 Methods of Studying Macromolecules.pdf
Biophysics Chapter 3 Methods of Studying Macromolecules.pdf
PKLI-Institute of Nursing and Allied Health Sciences Lahore , Pakistan.
 
Herbs Used in Cosmetic Formulations .pptx
Herbs Used in Cosmetic Formulations .pptxHerbs Used in Cosmetic Formulations .pptx
Herbs Used in Cosmetic Formulations .pptx
RAJU THENGE
 
THE STG QUIZ GROUP D.pptx quiz by Ridip Hazarika
THE STG QUIZ GROUP D.pptx   quiz by Ridip HazarikaTHE STG QUIZ GROUP D.pptx   quiz by Ridip Hazarika
THE STG QUIZ GROUP D.pptx quiz by Ridip Hazarika
Ridip Hazarika
 
How to Manage Purchase Alternatives in Odoo 18
How to Manage Purchase Alternatives in Odoo 18How to Manage Purchase Alternatives in Odoo 18
How to Manage Purchase Alternatives in Odoo 18
Celine George
 
apa-style-referencing-visual-guide-2025.pdf
apa-style-referencing-visual-guide-2025.pdfapa-style-referencing-visual-guide-2025.pdf
apa-style-referencing-visual-guide-2025.pdf
Ishika Ghosh
 
dynastic art of the Pallava dynasty south India
dynastic art of the Pallava dynasty south Indiadynastic art of the Pallava dynasty south India
dynastic art of the Pallava dynasty south India
PrachiSontakke5
 
pulse ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
pulse  ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulsepulse  ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
pulse ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
sushreesangita003
 
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptxSCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
Ronisha Das
 
Contact Lens:::: An Overview.pptx.: Optometry
Contact Lens:::: An Overview.pptx.: OptometryContact Lens:::: An Overview.pptx.: Optometry
Contact Lens:::: An Overview.pptx.: Optometry
MushahidRaza8
 
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - WorksheetCBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
Sritoma Majumder
 
Metamorphosis: Life's Transformative Journey
Metamorphosis: Life's Transformative JourneyMetamorphosis: Life's Transformative Journey
Metamorphosis: Life's Transformative Journey
Arshad Shaikh
 
Sugar-Sensing Mechanism in plants....pptx
Sugar-Sensing Mechanism in plants....pptxSugar-Sensing Mechanism in plants....pptx
Sugar-Sensing Mechanism in plants....pptx
Dr. Renu Jangid
 
Odoo Inventory Rules and Routes v17 - Odoo Slides
Odoo Inventory Rules and Routes v17 - Odoo SlidesOdoo Inventory Rules and Routes v17 - Odoo Slides
Odoo Inventory Rules and Routes v17 - Odoo Slides
Celine George
 
How to manage Multiple Warehouses for multiple floors in odoo point of sale
How to manage Multiple Warehouses for multiple floors in odoo point of saleHow to manage Multiple Warehouses for multiple floors in odoo point of sale
How to manage Multiple Warehouses for multiple floors in odoo point of sale
Celine George
 
2541William_McCollough_DigitalDetox.docx
2541William_McCollough_DigitalDetox.docx2541William_McCollough_DigitalDetox.docx
2541William_McCollough_DigitalDetox.docx
contactwilliamm2546
 
To study the nervous system of insect.pptx
To study the nervous system of insect.pptxTo study the nervous system of insect.pptx
To study the nervous system of insect.pptx
Arshad Shaikh
 
BỘ ĐỀ TUYỂN SINH VÀO LỚP 10 TIẾNG ANH - 25 ĐỀ THI BÁM SÁT CẤU TRÚC MỚI NHẤT, ...
BỘ ĐỀ TUYỂN SINH VÀO LỚP 10 TIẾNG ANH - 25 ĐỀ THI BÁM SÁT CẤU TRÚC MỚI NHẤT, ...BỘ ĐỀ TUYỂN SINH VÀO LỚP 10 TIẾNG ANH - 25 ĐỀ THI BÁM SÁT CẤU TRÚC MỚI NHẤT, ...
BỘ ĐỀ TUYỂN SINH VÀO LỚP 10 TIẾNG ANH - 25 ĐỀ THI BÁM SÁT CẤU TRÚC MỚI NHẤT, ...
Nguyen Thanh Tu Collection
 
Grade 2 - Mathematics - Printable Worksheet
Grade 2 - Mathematics - Printable WorksheetGrade 2 - Mathematics - Printable Worksheet
Grade 2 - Mathematics - Printable Worksheet
Sritoma Majumder
 
PHYSIOLOGY MCQS By DR. NASIR MUSTAFA (PHYSIOLOGY)
PHYSIOLOGY MCQS By DR. NASIR MUSTAFA (PHYSIOLOGY)PHYSIOLOGY MCQS By DR. NASIR MUSTAFA (PHYSIOLOGY)
PHYSIOLOGY MCQS By DR. NASIR MUSTAFA (PHYSIOLOGY)
Dr. Nasir Mustafa
 
Presentation of the MIPLM subject matter expert Erdem Kaya
Presentation of the MIPLM subject matter expert Erdem KayaPresentation of the MIPLM subject matter expert Erdem Kaya
Presentation of the MIPLM subject matter expert Erdem Kaya
MIPLM
 
Herbs Used in Cosmetic Formulations .pptx
Herbs Used in Cosmetic Formulations .pptxHerbs Used in Cosmetic Formulations .pptx
Herbs Used in Cosmetic Formulations .pptx
RAJU THENGE
 
THE STG QUIZ GROUP D.pptx quiz by Ridip Hazarika
THE STG QUIZ GROUP D.pptx   quiz by Ridip HazarikaTHE STG QUIZ GROUP D.pptx   quiz by Ridip Hazarika
THE STG QUIZ GROUP D.pptx quiz by Ridip Hazarika
Ridip Hazarika
 
How to Manage Purchase Alternatives in Odoo 18
How to Manage Purchase Alternatives in Odoo 18How to Manage Purchase Alternatives in Odoo 18
How to Manage Purchase Alternatives in Odoo 18
Celine George
 
apa-style-referencing-visual-guide-2025.pdf
apa-style-referencing-visual-guide-2025.pdfapa-style-referencing-visual-guide-2025.pdf
apa-style-referencing-visual-guide-2025.pdf
Ishika Ghosh
 
dynastic art of the Pallava dynasty south India
dynastic art of the Pallava dynasty south Indiadynastic art of the Pallava dynasty south India
dynastic art of the Pallava dynasty south India
PrachiSontakke5
 
Ad

Link List Programming Linked List in Cpp

  • 1. Programming Linked List class LinkedList{ // declaration of the node struct node{ int info; node *next; }; //private variable declared node *start; public: LinkedList() // Constructor { start = NULL; } //public fucntion declared void AddAtBeg(int); void AddAfter(int, int); void Delete(); void Count(); void Search(int); void Display(); }; 20
  • 2. Programming Linked List // following function will add new element at the beginning // also used to create first node void LinkedList::AddAtBeg(int data) { node * newNode; newNode = new node; newNode->info = data; newNode->next = start; start = newNode; }/*End of addatbeg()*/ 21
  • 3. Programming Linked List //This function will add new element at any position void LinkedList::AddAfter(int data, int pos) { node *newNode, *q; q = start; if(q == NULL) { cout<<"nnEmpty linked list" << endl; return; } //Finding the position in the linked list to insert for(int i = 1; i < pos; i++) q = q->next; newNode = new node; newNode->info = data; newNode->next = q->next; q->next = newNode; } 22
  • 4. Programming Linked List void LinkedList::Delete() { node *tmp, *ptr; int data; if(start == NULL) { cout<<"nn List is empty"<<endl; return; } cout<<"nnEnter the element for deletion : "; cin>>data; // delete first node if(start->info == data) { tmp = start; start = start->next; delete(tmp); return; } 23
  • 5. ptr = start; while(ptr->info != data) { temp = ptr; ptr = ptr ->next; } tmp->next = ptr->next; delete(ptr); // Delete node in between, or last node }/*End of del()*/ 24
  • 6. Programming Linked List void LinkedList::Display() { // Fill in the code that displays the contents of the linked list } /*End of display() */ void LinkedList::Count() { // Fill in the code that counts the nodes of the linked list } /*End of count() */ void LinkedList::Search(int data) { // Fill in the code that will find the position of a node that holds the ‘data’ } 25
  • 7. Programming Linked List int main() { int choice, n, m, position, i; LinkedList po; while(1) { cout<<"1. Add at beginningn"; cout<<"2. Add after n"; cout<<"3. Deleten"; cout<<"4. Displayn"; cout<<"5. Countn"; 26
  • 8. Programming Linked List cout<<"6. Searchn" cout<<"7. Quitn"; cout<<"n Enter your choice:"; cin>> choice; switch(choice) { case 1: cout<<"nnEnter the element:"; cin>>m; po.AddAtBeg(m); break; 27
  • 9. Programming Linked List case 2: cout<<"nnEnter the element:"; cin>>m; cout<<"nPosition after inserted element:"; cin>>position; po.AddAfter(m,position); break; case 3: po.Delete(); break; case 4: po.Display(); break; case 5: po.Count(); break; case 6: cout<<"n nEnter the element to search:"; 28
  • 10. Programming Linked List cin>>m; po.Search(m); break; case 7: exit(0); default: c out<<" n nWron g choice "; }/*End of switch */ 29