SlideShare a Scribd company logo
#include
#include
using namespace std;
template class Node{
private:
T value;
Node *next;
public:
Node();
Node (T data);
T remove();
T getValue();
Node* getNext();
void setValue(T data);
void setNext(Node *nextNode);
};
template
Node::Node(){
T value =NULL;
}
template
Node::Node(T data){
T value=data;
}
template
T Node::getValue(){
return value;
}
template
Node* Node::getNext(){
return next;
}
template
void Node::setValue(T data){
T value=data;
}
template
void Node::setNext(Node *nextNode){
next=nextNode;
}
template class MyLinkedList{
Node start;
//Define a constructor
MyLinkedList()
{
start->setValue(0);
start->setNext(NULL);
}
//Member Functions:
// Adds a new element to the list
void add (T val)
{
/* creating a new node to hold value*/
Nodetemp(val,NULL);
/* If no start node till now, this node is made as start node*/
if (start->next == NULL)
{
start.setNext(temp);
}
/* if start node exists, insert new node at end of list*/
else
{
s = start->next;
/* locating end of list*/
while (s->next != NULL)
{
s= s->next;
}
temp->next = NULL;
/* attaching new node */
s->next = temp;
cout<<"Element Inserted"<next->next != NULL)
{
s = s->next;
}
//After locating the end node
ptr=s->next;
s->next=NULL;
//deletting end node
return ptr;
}
}
//Prints elements of the list
void printContent()
{
struct node *ptr = start;
cout<data;
ptr=ptr->next;
}
}
}
//Prints total number of elements
int getSize()
{
struct node *ptr, *s;
int count=0;
if (start == NULL)
{
cout<<"The List is empty"<next;
count=1;
while (ptr != NULL)
{
count++;
ptr=ptr->next;
}
return count;
}
//Returns true if there is no element in the list.
bool empty()
{
if(start==NULL)
{
return empty;
}
}
};
Solution
#include
#include
using namespace std;
template class Node{
private:
T value;
Node *next;
public:
Node();
Node (T data);
T remove();
T getValue();
Node* getNext();
void setValue(T data);
void setNext(Node *nextNode);
};
template
Node::Node(){
T value =NULL;
}
template
Node::Node(T data){
T value=data;
}
template
T Node::getValue(){
return value;
}
template
Node* Node::getNext(){
return next;
}
template
void Node::setValue(T data){
T value=data;
}
template
void Node::setNext(Node *nextNode){
next=nextNode;
}
template class MyLinkedList{
Node start;
//Define a constructor
MyLinkedList()
{
start->setValue(0);
start->setNext(NULL);
}
//Member Functions:
// Adds a new element to the list
void add (T val)
{
/* creating a new node to hold value*/
Nodetemp(val,NULL);
/* If no start node till now, this node is made as start node*/
if (start->next == NULL)
{
start.setNext(temp);
}
/* if start node exists, insert new node at end of list*/
else
{
s = start->next;
/* locating end of list*/
while (s->next != NULL)
{
s= s->next;
}
temp->next = NULL;
/* attaching new node */
s->next = temp;
cout<<"Element Inserted"<next->next != NULL)
{
s = s->next;
}
//After locating the end node
ptr=s->next;
s->next=NULL;
//deletting end node
return ptr;
}
}
//Prints elements of the list
void printContent()
{
struct node *ptr = start;
cout<data;
ptr=ptr->next;
}
}
}
//Prints total number of elements
int getSize()
{
struct node *ptr, *s;
int count=0;
if (start == NULL)
{
cout<<"The List is empty"<next;
count=1;
while (ptr != NULL)
{
count++;
ptr=ptr->next;
}
return count;
}
//Returns true if there is no element in the list.
bool empty()
{
if(start==NULL)
{
return empty;
}
}
};

More Related Content

PDF
could you implement this function please, im having issues with it..pdf
DOCX
4) 15 points- Linked Lists- Consider the linked list template-type.docx
DOCX
C++ Please write the whole code that is needed for this assignment- wr.docx
PDF
#includeiostream#includecstdio#includecstdlibusing names.pdf
PPT
Data structures cs301 power point slides lecture 03
PDF
This assignment and the next (#5) involve design and development of a.pdf
PDF
In C++Write a recursive function to determine whether or not a Lin.pdf
PDF
Write a program to implement below operations with both singly and d.pdf
could you implement this function please, im having issues with it..pdf
4) 15 points- Linked Lists- Consider the linked list template-type.docx
C++ Please write the whole code that is needed for this assignment- wr.docx
#includeiostream#includecstdio#includecstdlibusing names.pdf
Data structures cs301 power point slides lecture 03
This assignment and the next (#5) involve design and development of a.pdf
In C++Write a recursive function to determine whether or not a Lin.pdf
Write a program to implement below operations with both singly and d.pdf

Similar to #include iostream #include cstddefusing namespace std;temp.pdf (20)

PDF
Inspect the class declaration for a doubly-linked list node in Node-h-.pdf
PDF
Below binary program is usefell to you#include iostreamtem.pdf
PDF
Assignment isPage 349-350 #4 and #5 Use the Linked List lab.pdf
PPTX
Link List Programming Linked List in Cpp
PPT
computer notes - Data Structures - 3
PDF
Lab-2.4 101.pdf
PPT
dynamicList.ppt
DOCX
lab08build.bat@echo offclsset DRIVE_LETTER=1s.docx
DOCX
Linked Stack program.docx
PDF
mainpublic class AssignmentThree {    public static void ma.pdf
PDF
C code on linked list #include stdio.h #include stdlib.h.pdf
PDF
How do I fix it in LinkedList.javaLabProgram.javaLinkedList.jav.pdf
PDF
TutorialII_Updated____niceupdateprogram.pdf
PDF
Using the provided table interface table.h and the sample linked lis.pdf
DOCX
Lab Week 2 Game Programming.docx
PDF
Sorted number list implementation with linked listsStep 1 Inspec.pdf
PDF
#includeiostream #includecstdio #includecstdlib using na.pdf
DOCX
#include stdafx.h #include iostream using namespace std;vo.docx
PDF
Need done for Date Structures please! 4-18 LAB- Sorted number list imp.pdf
PDF
Note             Given Code modified as required and required met.pdf
Inspect the class declaration for a doubly-linked list node in Node-h-.pdf
Below binary program is usefell to you#include iostreamtem.pdf
Assignment isPage 349-350 #4 and #5 Use the Linked List lab.pdf
Link List Programming Linked List in Cpp
computer notes - Data Structures - 3
Lab-2.4 101.pdf
dynamicList.ppt
lab08build.bat@echo offclsset DRIVE_LETTER=1s.docx
Linked Stack program.docx
mainpublic class AssignmentThree {    public static void ma.pdf
C code on linked list #include stdio.h #include stdlib.h.pdf
How do I fix it in LinkedList.javaLabProgram.javaLinkedList.jav.pdf
TutorialII_Updated____niceupdateprogram.pdf
Using the provided table interface table.h and the sample linked lis.pdf
Lab Week 2 Game Programming.docx
Sorted number list implementation with linked listsStep 1 Inspec.pdf
#includeiostream #includecstdio #includecstdlib using na.pdf
#include stdafx.h #include iostream using namespace std;vo.docx
Need done for Date Structures please! 4-18 LAB- Sorted number list imp.pdf
Note             Given Code modified as required and required met.pdf
Ad

More from karan8801 (20)

PDF
1. C.HIV is a virus it can be tansmitted through body fluids liks .pdf
PDF
omparative historical research is a method of social science that e.pdf
PDF
1 .D 2.BSolution 1 .D 2.B.pdf
PDF
where is it .pdf
PDF
The name of the reaction is aldol condesation (Cl.pdf
PDF
Step1 3 moles of H2O react with Cr metal = 2moles.pdf
PDF
sp2 - sp2 .pdf
PDF
Part A neutralizes acids - base Part B produces.pdf
PDF
Lewis Acid Base Reaction .pdf
PDF
KOH ==== K+ (aq) + OH-(aq) [OH-] =9.710^-5 [H.pdf
PDF
It is a reaction for secondary amines .Option 2 i.pdf
PDF
fluorene is mobile phase and fluorenone is statio.pdf
PDF
equivalent mass is 27.9 . so Molecular massmole.pdf
PDF
There is no solutionSolutionThere is no solution.pdf
PDF
This is a case of allopatric speciation. In this case lice from gori.pdf
PDF
d. 8 The bonding electrons are the electrons taki.pdf
PDF
The genetical changes of single locus are responsible for divergent .pdf
PDF
The corrects answers areThr and Asn are polar amino acids.Isole.pdf
PDF
Since Z4 has an element of order 4,Z4, its a cyclic group of order 4.pdf
PDF
selected palntsxerophyte verus mesophyte========================.pdf
1. C.HIV is a virus it can be tansmitted through body fluids liks .pdf
omparative historical research is a method of social science that e.pdf
1 .D 2.BSolution 1 .D 2.B.pdf
where is it .pdf
The name of the reaction is aldol condesation (Cl.pdf
Step1 3 moles of H2O react with Cr metal = 2moles.pdf
sp2 - sp2 .pdf
Part A neutralizes acids - base Part B produces.pdf
Lewis Acid Base Reaction .pdf
KOH ==== K+ (aq) + OH-(aq) [OH-] =9.710^-5 [H.pdf
It is a reaction for secondary amines .Option 2 i.pdf
fluorene is mobile phase and fluorenone is statio.pdf
equivalent mass is 27.9 . so Molecular massmole.pdf
There is no solutionSolutionThere is no solution.pdf
This is a case of allopatric speciation. In this case lice from gori.pdf
d. 8 The bonding electrons are the electrons taki.pdf
The genetical changes of single locus are responsible for divergent .pdf
The corrects answers areThr and Asn are polar amino acids.Isole.pdf
Since Z4 has an element of order 4,Z4, its a cyclic group of order 4.pdf
selected palntsxerophyte verus mesophyte========================.pdf
Ad

Recently uploaded (20)

PDF
01-Introduction-to-Information-Management.pdf
PPTX
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PDF
Insiders guide to clinical Medicine.pdf
PPTX
Cell Structure & Organelles in detailed.
PPTX
Renaissance Architecture: A Journey from Faith to Humanism
PPTX
Lesson notes of climatology university.
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PDF
TR - Agricultural Crops Production NC III.pdf
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PDF
Sports Quiz easy sports quiz sports quiz
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PPTX
PPH.pptx obstetrics and gynecology in nursing
PDF
Pre independence Education in Inndia.pdf
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PDF
Computing-Curriculum for Schools in Ghana
PPTX
Institutional Correction lecture only . . .
01-Introduction-to-Information-Management.pdf
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
Pharmacology of Heart Failure /Pharmacotherapy of CHF
Insiders guide to clinical Medicine.pdf
Cell Structure & Organelles in detailed.
Renaissance Architecture: A Journey from Faith to Humanism
Lesson notes of climatology university.
human mycosis Human fungal infections are called human mycosis..pptx
TR - Agricultural Crops Production NC III.pdf
Supply Chain Operations Speaking Notes -ICLT Program
Sports Quiz easy sports quiz sports quiz
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
2.FourierTransform-ShortQuestionswithAnswers.pdf
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PPH.pptx obstetrics and gynecology in nursing
Pre independence Education in Inndia.pdf
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
Computing-Curriculum for Schools in Ghana
Institutional Correction lecture only . . .

#include iostream #include cstddefusing namespace std;temp.pdf

  • 1. #include #include using namespace std; template class Node{ private: T value; Node *next; public: Node(); Node (T data); T remove(); T getValue(); Node* getNext(); void setValue(T data); void setNext(Node *nextNode); }; template Node::Node(){ T value =NULL; } template Node::Node(T data){ T value=data; } template T Node::getValue(){ return value; } template Node* Node::getNext(){ return next; } template void Node::setValue(T data){ T value=data;
  • 2. } template void Node::setNext(Node *nextNode){ next=nextNode; } template class MyLinkedList{ Node start; //Define a constructor MyLinkedList() { start->setValue(0); start->setNext(NULL); } //Member Functions: // Adds a new element to the list void add (T val) { /* creating a new node to hold value*/ Nodetemp(val,NULL); /* If no start node till now, this node is made as start node*/ if (start->next == NULL) { start.setNext(temp); } /* if start node exists, insert new node at end of list*/ else { s = start->next; /* locating end of list*/ while (s->next != NULL) { s= s->next; } temp->next = NULL; /* attaching new node */
  • 3. s->next = temp; cout<<"Element Inserted"<next->next != NULL) { s = s->next; } //After locating the end node ptr=s->next; s->next=NULL; //deletting end node return ptr; } } //Prints elements of the list void printContent() { struct node *ptr = start; cout<data; ptr=ptr->next; } } } //Prints total number of elements int getSize() { struct node *ptr, *s; int count=0; if (start == NULL) { cout<<"The List is empty"<next; count=1; while (ptr != NULL) { count++; ptr=ptr->next; }
  • 4. return count; } //Returns true if there is no element in the list. bool empty() { if(start==NULL) { return empty; } } }; Solution #include #include using namespace std; template class Node{ private: T value; Node *next; public: Node(); Node (T data); T remove(); T getValue(); Node* getNext(); void setValue(T data); void setNext(Node *nextNode); }; template Node::Node(){ T value =NULL; }
  • 5. template Node::Node(T data){ T value=data; } template T Node::getValue(){ return value; } template Node* Node::getNext(){ return next; } template void Node::setValue(T data){ T value=data; } template void Node::setNext(Node *nextNode){ next=nextNode; } template class MyLinkedList{ Node start; //Define a constructor MyLinkedList() { start->setValue(0); start->setNext(NULL); } //Member Functions: // Adds a new element to the list void add (T val) { /* creating a new node to hold value*/ Nodetemp(val,NULL); /* If no start node till now, this node is made as start node*/
  • 6. if (start->next == NULL) { start.setNext(temp); } /* if start node exists, insert new node at end of list*/ else { s = start->next; /* locating end of list*/ while (s->next != NULL) { s= s->next; } temp->next = NULL; /* attaching new node */ s->next = temp; cout<<"Element Inserted"<next->next != NULL) { s = s->next; } //After locating the end node ptr=s->next; s->next=NULL; //deletting end node return ptr; } } //Prints elements of the list void printContent() { struct node *ptr = start; cout<data; ptr=ptr->next; } }
  • 7. } //Prints total number of elements int getSize() { struct node *ptr, *s; int count=0; if (start == NULL) { cout<<"The List is empty"<next; count=1; while (ptr != NULL) { count++; ptr=ptr->next; } return count; } //Returns true if there is no element in the list. bool empty() { if(start==NULL) { return empty; } } };