SlideShare a Scribd company logo
I need to fill-in //TODO's in .cpp file and in .h file
Could someone help me at least with few of them to give me an idea how deal with it.
***SinglyLinkedList.cpp
#include
#include
#include "SinglyLinkedList.h"
void test_constructor() {
SinglyLinkedList lst = {100, 200, 300, 400, 500};
assert(*lst.at(0) == 100);
assert(*lst.at(1) == 200);
assert(*lst.at(2) == 300);
assert(*lst.at(3) == 400);
assert(*lst.at(4) == 500);
assert(lst.size() == 5);
}
void test_remove() {
SinglyLinkedList lst = {100, 200, 300, 400, 500};
lst.remove(2);
assert(*lst.at(0) == 100);
assert(*lst.at(1) == 200);
assert(*lst.at(2) == 400);
assert(*lst.at(3) == 500);
assert(lst.size() == 4);
}
void test_insert() {
// TODO
}
void test_push_back() {
// TODO
}
void test_push_front() {
// TODO
}
void test_append() {
// TODO
}
void test_sum() {
// TODO
}
int main() {
test_constructor();
test_remove();
test_insert();
test_push_back();
test_push_front();
test_append();
test_sum();
}
***SinglyLinkedList.h
#include
#include
template
class SinglyLinkedList {
// Nested class representing the nodes in the list.
class SinglyLinkedListNode {
public:
// The value stored in this node.
T value;
// The next node in the sequence.
SinglyLinkedListNode *next;
SinglyLinkedListNode(T value) :
value(value), next(nullptr) {}
SinglyLinkedListNode(T value, SinglyLinkedListNode *next) :
value(value), next(next) {}
// Return the size (length) of the linked list.
std::size_t size();
};
SinglyLinkedListNode *head;
SinglyLinkedListNode *tail;
public:
// Constructs a new SinglyLinkedList from an initializer_list of type T[].
// This is mostly for convenience, especially when testing.
SinglyLinkedList(std::initializer_list items) : head(nullptr), tail(nullptr) {
if (items.size() == 0) {
return;
}
// initializer_lists were designed to be used iteratively,
// so thats what we do.
// Can you think of how to write this recursively?
auto it = items.begin();
while (it != items.end()) {
this->push_back(*it++);
}
}
// Return a pointer to the value at the given index.
// If the index is larger than the size of the list,
// return a nullptr.
//
// ASIDE: We will cover exceptions later.
T* at(std::size_t i);
// Pushes a new node onto the back of the list.
void push_back(T value);
// Pushes a new node onto the front of the list.
void push_front(T value);
// Return the size (length) of the linked list.
std::size_t size();
// Remove the specified node from the list.
void remove(std::size_t i);
// Insert the value at the index.
void insert(std::size_t i, T value);
// Append the given list to this one.
void append(SinglyLinkedList list);
};
template
T* SinglyLinkedList::at(std::size_t i) {
// TODO
}
template
void SinglyLinkedList::push_back(T value) {
// TODO
// Make sure that this is a O(1) operation!
}
template
void SinglyLinkedList::push_front(T value) {
// TODO
// Make sure that this is a O(1) operation!
}
template
void SinglyLinkedList::remove(std::size_t i) {
// TODO
// Don't forget to not only unlink the node, but to delete the memory.
}
template
void SinglyLinkedList::insert(std::size_t i, T value) {
// TODO
// Don't forget to not only unlink the node, but to delete the memory.
}
template
void SinglyLinkedList::append(SinglyLinkedList list) {
// TODO
}
template
std::size_t SinglyLinkedList::size() {
if (this->head == nullptr) {
return 0;
} else {
return this->head->size();
}
}
template
std::size_t SinglyLinkedList::SinglyLinkedListNode::size() {
if (this == nullptr) {
return 0;
} else if (this->next == nullptr) {
return 1;
} else {
return 1 + this->next->size();
}
}
// Takes a reference to a list of integers as an argument,
// and returns the sum of the items in the list.
long sum(const SinglyLinkedList& list) {
// TODO
}
Solution
#include
#include
#include
struct node
{
int info;
struct node *next;
}*start;
class SingleLinkedList
{
public:
node* create_node(int);
void insert_begin();
void insert_pos();
void insert_last();
void delete_pos();
void sort();
void search();
void update();
void reverse();
void display();
SingleLinkedList()
{
start = NULL;
}
};
void main()
{
int choice, nodes, element, position, i;
SingleLinkedList sl;
start = NULL;
while (1)
{
cout<>choice;
switch(choice)
{
case 1:
cout<<"Inserting Node at Beginning: "<info = value;
temp->next = NULL;
return temp;
}
}
void SingleLinkedList::insert_begin()
{
int value;
cout<<"Enter the value to be inserted: ";
cin>>value;
struct node *temp, *p;
temp = create_node(value);
if (start == NULL)
{
start = temp;
start->next = NULL;
}
else
{
p = start;
start = temp;
start->next = p;
}
cout<<"Element Inserted at beginning"<>value;
struct node *temp, *s;
temp = create_node(value);
s = start;
while (s->next != NULL)
{
s = s->next;
}
temp->next = NULL;
s->next = temp;
cout<<"Element Inserted at last"<>value;
struct node *temp, *s, *ptr;
temp = create_node(value);
cout<<"Enter the postion at which node to be inserted: ";
cin>>pos;
int i;
s = start;
while (s != NULL)
{
s = s->next;
counter++;
}
if (pos == 1)
{
if (start == NULL)
{
start = temp;
start->next = NULL;
}
else
{
ptr = start;
start = temp;
start->next = ptr;
}
}
else if (pos > 1 && pos <= counter)
{
s = start;
for (i = 1; i < pos; i++)
{
ptr = s;
s = s->next;
}
ptr->next = temp;
temp->next = s;
}
else
{
cout<<"Positon out of range"<next;s !=NULL;s = s->next)
{
if (ptr->info > s->info)
{
value = ptr->info;
ptr->info = s->info;
s->info = value;
}
}
ptr = ptr->next;
}
}
void SingleLinkedList::delete_pos()
{
int pos, i, counter = 0;
if (start == NULL)
{
cout<<"List is empty"<>pos;
struct node *s, *ptr;
s = start;
if (pos == 1)
{
start = s->next;
}
else
{
while (s != NULL)
{
s = s->next;
counter++;
}
if (pos > 0 && pos <= counter)
{
s = start;
for (i = 1;i < pos;i++)
{
ptr = s;
s = s->next;
}
ptr->next = s->next;
}
else
{
cout<<"Position out of range"<>pos;
cout<<"Enter the new value: ";
cin>>value;
struct node *s, *ptr;
s = start;
if (pos == 1)
{
start->info = value;
}
else
{
for (i = 0;i < pos - 1;i++)
{
if (s == NULL)
{
cout<<"There are less than "<next;
}
s->info = value;
}
cout<<"Node Updated"<>value;
struct node *s;
s = start;
while (s != NULL)
{
pos++;
if (s->info == value)
{
flag = true;
cout<<"Element "<next;
}
if (!flag)
cout<<"Element "<next == NULL)
{
return;
}
ptr1 = start;
ptr2 = ptr1->next;
ptr3 = ptr2->next;
ptr1->next = NULL;
ptr2->next = ptr1;
while (ptr3 != NULL)
{
ptr1 = ptr2;
ptr2 = ptr3;
ptr3 = ptr3->next;
ptr2->next = ptr1;
}
start = ptr2;
}
void SingleLinkedList::display()
{
struct node *temp;
if (start == NULL)
{
cout<<"The List is Empty"<info<<"->";
temp = temp->next;
}
cout<<"NULL"<

More Related Content

Similar to I need to fill-in TODOs in .cpp file and in .h file Could some.pdf (20)

PDF
Implement the unsorted single linked list as we did in the class and .pdf
arihantstoneart
 
PDF
–PLS write program in c++Recursive Linked List OperationsWrite a.pdf
pasqualealvarez467
 
PDF
implement the ListLinked ADT (the declaration is given in ListLinked.pdf
FOREVERPRODUCTCHD
 
PDF
#include iostream #include cstddefusing namespace std;temp.pdf
karan8801
 
PDF
#ifndef LINKED_LIST_ #define LINKED_LIST_ templateclass It.pdf
angelsfashion1
 
PDF
Complete the provided partial C++ Linked List program. Main.cpp is g.pdf
rajkumarm401
 
PDF
In C++Write a recursive function to determine whether or not a Lin.pdf
flashfashioncasualwe
 
DOCX
Linked lists
George Scott IV
 
PDF
I have been tasked to write a code for a Singly Linked list that inc.pdf
arkmuzikllc
 
PDF
Create a link list. Add some nodes to it, search and delete nodes fro.pdf
hadpadrrajeshh
 
DOCX
Bsf23006565 dsa 3rd assignment.docx............
XEON14
 
PDF
Please need help on following program using c++ language. Please inc.pdf
nitinarora01
 
DOCX
Program 8 C++newproblems.txt12333142013KristinBrewer1032823.docx
wkyra78
 
PPTX
How to sort linked list using sorthing method.pptx
dishantghumi
 
PPTX
DSA(1).pptx
DaniyalAli81
 
PDF
This assignment and the next (#5) involve design and development of a.pdf
EricvtJFraserr
 
PDF
Please refer this solution. This is working file for IntegersHeade.pdf
sooryasalini
 
PDF
C++ Doubly-Linked ListsThe goal of the exercise is to implement a.pdf
poblettesedanoree498
 
PDF
Template LinkedList;I am using templates to make some linkedLists.pdf
fatoryoutlets
 
Implement the unsorted single linked list as we did in the class and .pdf
arihantstoneart
 
–PLS write program in c++Recursive Linked List OperationsWrite a.pdf
pasqualealvarez467
 
implement the ListLinked ADT (the declaration is given in ListLinked.pdf
FOREVERPRODUCTCHD
 
#include iostream #include cstddefusing namespace std;temp.pdf
karan8801
 
#ifndef LINKED_LIST_ #define LINKED_LIST_ templateclass It.pdf
angelsfashion1
 
Complete the provided partial C++ Linked List program. Main.cpp is g.pdf
rajkumarm401
 
In C++Write a recursive function to determine whether or not a Lin.pdf
flashfashioncasualwe
 
Linked lists
George Scott IV
 
I have been tasked to write a code for a Singly Linked list that inc.pdf
arkmuzikllc
 
Create a link list. Add some nodes to it, search and delete nodes fro.pdf
hadpadrrajeshh
 
Bsf23006565 dsa 3rd assignment.docx............
XEON14
 
Please need help on following program using c++ language. Please inc.pdf
nitinarora01
 
Program 8 C++newproblems.txt12333142013KristinBrewer1032823.docx
wkyra78
 
How to sort linked list using sorthing method.pptx
dishantghumi
 
DSA(1).pptx
DaniyalAli81
 
This assignment and the next (#5) involve design and development of a.pdf
EricvtJFraserr
 
Please refer this solution. This is working file for IntegersHeade.pdf
sooryasalini
 
C++ Doubly-Linked ListsThe goal of the exercise is to implement a.pdf
poblettesedanoree498
 
Template LinkedList;I am using templates to make some linkedLists.pdf
fatoryoutlets
 

More from forladies (20)

PDF
You isolated an enveloped RNA virus. Purified RNA is not capable of .pdf
forladies
 
PDF
What properties should the following molecules NOT have in common (S.pdf
forladies
 
PDF
What is the difference between Schedule C and Schedule E income (i.e.pdf
forladies
 
PDF
What are the ethical and legal concerns associated with managing tel.pdf
forladies
 
PDF
Using the Graphical User Interface (GUI)Create a user nam.pdf
forladies
 
PDF
The adjusting entry to record the salaries earned due to employees f.pdf
forladies
 
PDF
TF A document type definition (DTD) can be referenced by many Exten.pdf
forladies
 
PDF
Summarize the first and the second checkpoints during T cell develop.pdf
forladies
 
PDF
PLEASE HELP!!Loren Seguara and Dale Johnson both work for Southern.pdf
forladies
 
PDF
Please answer the following at the bottom of the case. ThanksTo ne.pdf
forladies
 
PDF
Mitchell sets sail for the Chemiosmotic New World, despite dire w.pdf
forladies
 
PDF
Learn the genetics vocabulary (see HW4)] For each of the following ge.pdf
forladies
 
PDF
If nominal GDP is 28000 and the money supply is 7000, what is velocit.pdf
forladies
 
PDF
Investments in trade securities are always short term investments. T.pdf
forladies
 
PDF
Information Securityfind an article online discussing defense-in-d.pdf
forladies
 
PDF
implement the following funtions. myg1 and myg2 are seperate. x and .pdf
forladies
 
PDF
If two peers share a link in the overlay (they are neighbors in the .pdf
forladies
 
PDF
how important is Negative Emotionality to an accounting career plea.pdf
forladies
 
PDF
How do I know whether miscellaneous expense goes on top or bottom of.pdf
forladies
 
PDF
Given a 1024 by 1024 RAM block, answer the following questions a) If.pdf
forladies
 
You isolated an enveloped RNA virus. Purified RNA is not capable of .pdf
forladies
 
What properties should the following molecules NOT have in common (S.pdf
forladies
 
What is the difference between Schedule C and Schedule E income (i.e.pdf
forladies
 
What are the ethical and legal concerns associated with managing tel.pdf
forladies
 
Using the Graphical User Interface (GUI)Create a user nam.pdf
forladies
 
The adjusting entry to record the salaries earned due to employees f.pdf
forladies
 
TF A document type definition (DTD) can be referenced by many Exten.pdf
forladies
 
Summarize the first and the second checkpoints during T cell develop.pdf
forladies
 
PLEASE HELP!!Loren Seguara and Dale Johnson both work for Southern.pdf
forladies
 
Please answer the following at the bottom of the case. ThanksTo ne.pdf
forladies
 
Mitchell sets sail for the Chemiosmotic New World, despite dire w.pdf
forladies
 
Learn the genetics vocabulary (see HW4)] For each of the following ge.pdf
forladies
 
If nominal GDP is 28000 and the money supply is 7000, what is velocit.pdf
forladies
 
Investments in trade securities are always short term investments. T.pdf
forladies
 
Information Securityfind an article online discussing defense-in-d.pdf
forladies
 
implement the following funtions. myg1 and myg2 are seperate. x and .pdf
forladies
 
If two peers share a link in the overlay (they are neighbors in the .pdf
forladies
 
how important is Negative Emotionality to an accounting career plea.pdf
forladies
 
How do I know whether miscellaneous expense goes on top or bottom of.pdf
forladies
 
Given a 1024 by 1024 RAM block, answer the following questions a) If.pdf
forladies
 

Recently uploaded (20)

PDF
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 - GLOBAL SUCCESS - CẢ NĂM - NĂM 2024 (VOCABULARY, ...
Nguyen Thanh Tu Collection
 
PPTX
How to Manage Promotions in Odoo 18 Sales
Celine George
 
PDF
community health nursing question paper 2.pdf
Prince kumar
 
PPTX
ASRB NET 2023 PREVIOUS YEAR QUESTION PAPER GENETICS AND PLANT BREEDING BY SAT...
Krashi Coaching
 
PPTX
Gall bladder, Small intestine and Large intestine.pptx
rekhapositivity
 
PDF
ARAL-Orientation_Morning-Session_Day-11.pdf
JoelVilloso1
 
PPTX
Views on Education of Indian Thinkers Mahatma Gandhi.pptx
ShrutiMahanta1
 
PPTX
Accounting Skills Paper-I, Preparation of Vouchers
Dr. Sushil Bansode
 
PDF
CONCURSO DE POESIA “POETUFAS – PASSOS SUAVES PELO VERSO.pdf
Colégio Santa Teresinha
 
PPTX
Explorando Recursos do Summer '25: Dicas Essenciais - 02
Mauricio Alexandre Silva
 
PPTX
LEGAL ASPECTS OF PSYCHIATRUC NURSING.pptx
PoojaSen20
 
PPTX
Optimizing Cancer Screening With MCED Technologies: From Science to Practical...
i3 Health
 
PPTX
How to Configure Lost Reasons in Odoo 18 CRM
Celine George
 
PPTX
How to Configure Prepayments in Odoo 18 Sales
Celine George
 
PDF
IMP NAAC REFORMS 2024 - 10 Attributes.pdf
BHARTIWADEKAR
 
PPTX
2025 Winter SWAYAM NPTEL & A Student.pptx
Utsav Yagnik
 
PPTX
Pyhton with Mysql to perform CRUD operations.pptx
Ramakrishna Reddy Bijjam
 
PPTX
Capitol Doctoral Presentation -July 2025.pptx
CapitolTechU
 
PPTX
Unit 2 COMMERCIAL BANKING, Corporate banking.pptx
AnubalaSuresh1
 
PDF
Zoology (Animal Physiology) practical Manual
raviralanaresh2
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 - GLOBAL SUCCESS - CẢ NĂM - NĂM 2024 (VOCABULARY, ...
Nguyen Thanh Tu Collection
 
How to Manage Promotions in Odoo 18 Sales
Celine George
 
community health nursing question paper 2.pdf
Prince kumar
 
ASRB NET 2023 PREVIOUS YEAR QUESTION PAPER GENETICS AND PLANT BREEDING BY SAT...
Krashi Coaching
 
Gall bladder, Small intestine and Large intestine.pptx
rekhapositivity
 
ARAL-Orientation_Morning-Session_Day-11.pdf
JoelVilloso1
 
Views on Education of Indian Thinkers Mahatma Gandhi.pptx
ShrutiMahanta1
 
Accounting Skills Paper-I, Preparation of Vouchers
Dr. Sushil Bansode
 
CONCURSO DE POESIA “POETUFAS – PASSOS SUAVES PELO VERSO.pdf
Colégio Santa Teresinha
 
Explorando Recursos do Summer '25: Dicas Essenciais - 02
Mauricio Alexandre Silva
 
LEGAL ASPECTS OF PSYCHIATRUC NURSING.pptx
PoojaSen20
 
Optimizing Cancer Screening With MCED Technologies: From Science to Practical...
i3 Health
 
How to Configure Lost Reasons in Odoo 18 CRM
Celine George
 
How to Configure Prepayments in Odoo 18 Sales
Celine George
 
IMP NAAC REFORMS 2024 - 10 Attributes.pdf
BHARTIWADEKAR
 
2025 Winter SWAYAM NPTEL & A Student.pptx
Utsav Yagnik
 
Pyhton with Mysql to perform CRUD operations.pptx
Ramakrishna Reddy Bijjam
 
Capitol Doctoral Presentation -July 2025.pptx
CapitolTechU
 
Unit 2 COMMERCIAL BANKING, Corporate banking.pptx
AnubalaSuresh1
 
Zoology (Animal Physiology) practical Manual
raviralanaresh2
 

I need to fill-in TODOs in .cpp file and in .h file Could some.pdf

  • 1. I need to fill-in //TODO's in .cpp file and in .h file Could someone help me at least with few of them to give me an idea how deal with it. ***SinglyLinkedList.cpp #include #include #include "SinglyLinkedList.h" void test_constructor() { SinglyLinkedList lst = {100, 200, 300, 400, 500}; assert(*lst.at(0) == 100); assert(*lst.at(1) == 200); assert(*lst.at(2) == 300); assert(*lst.at(3) == 400); assert(*lst.at(4) == 500); assert(lst.size() == 5); } void test_remove() { SinglyLinkedList lst = {100, 200, 300, 400, 500}; lst.remove(2); assert(*lst.at(0) == 100); assert(*lst.at(1) == 200); assert(*lst.at(2) == 400); assert(*lst.at(3) == 500); assert(lst.size() == 4); } void test_insert() { // TODO } void test_push_back() { // TODO } void test_push_front() { // TODO } void test_append() { // TODO
  • 2. } void test_sum() { // TODO } int main() { test_constructor(); test_remove(); test_insert(); test_push_back(); test_push_front(); test_append(); test_sum(); } ***SinglyLinkedList.h #include #include template class SinglyLinkedList { // Nested class representing the nodes in the list. class SinglyLinkedListNode { public: // The value stored in this node. T value; // The next node in the sequence. SinglyLinkedListNode *next; SinglyLinkedListNode(T value) : value(value), next(nullptr) {} SinglyLinkedListNode(T value, SinglyLinkedListNode *next) : value(value), next(next) {} // Return the size (length) of the linked list. std::size_t size(); }; SinglyLinkedListNode *head; SinglyLinkedListNode *tail; public: // Constructs a new SinglyLinkedList from an initializer_list of type T[].
  • 3. // This is mostly for convenience, especially when testing. SinglyLinkedList(std::initializer_list items) : head(nullptr), tail(nullptr) { if (items.size() == 0) { return; } // initializer_lists were designed to be used iteratively, // so thats what we do. // Can you think of how to write this recursively? auto it = items.begin(); while (it != items.end()) { this->push_back(*it++); } } // Return a pointer to the value at the given index. // If the index is larger than the size of the list, // return a nullptr. // // ASIDE: We will cover exceptions later. T* at(std::size_t i); // Pushes a new node onto the back of the list. void push_back(T value); // Pushes a new node onto the front of the list. void push_front(T value); // Return the size (length) of the linked list. std::size_t size(); // Remove the specified node from the list. void remove(std::size_t i); // Insert the value at the index. void insert(std::size_t i, T value); // Append the given list to this one. void append(SinglyLinkedList list); }; template T* SinglyLinkedList::at(std::size_t i) { // TODO }
  • 4. template void SinglyLinkedList::push_back(T value) { // TODO // Make sure that this is a O(1) operation! } template void SinglyLinkedList::push_front(T value) { // TODO // Make sure that this is a O(1) operation! } template void SinglyLinkedList::remove(std::size_t i) { // TODO // Don't forget to not only unlink the node, but to delete the memory. } template void SinglyLinkedList::insert(std::size_t i, T value) { // TODO // Don't forget to not only unlink the node, but to delete the memory. } template void SinglyLinkedList::append(SinglyLinkedList list) { // TODO } template std::size_t SinglyLinkedList::size() { if (this->head == nullptr) { return 0; } else { return this->head->size(); } } template std::size_t SinglyLinkedList::SinglyLinkedListNode::size() { if (this == nullptr) { return 0;
  • 5. } else if (this->next == nullptr) { return 1; } else { return 1 + this->next->size(); } } // Takes a reference to a list of integers as an argument, // and returns the sum of the items in the list. long sum(const SinglyLinkedList& list) { // TODO } Solution #include #include #include struct node { int info; struct node *next; }*start; class SingleLinkedList { public: node* create_node(int); void insert_begin(); void insert_pos(); void insert_last(); void delete_pos(); void sort(); void search(); void update(); void reverse(); void display(); SingleLinkedList()
  • 6. { start = NULL; } }; void main() { int choice, nodes, element, position, i; SingleLinkedList sl; start = NULL; while (1) { cout<>choice; switch(choice) { case 1: cout<<"Inserting Node at Beginning: "<info = value; temp->next = NULL; return temp; } } void SingleLinkedList::insert_begin() { int value; cout<<"Enter the value to be inserted: "; cin>>value; struct node *temp, *p; temp = create_node(value); if (start == NULL) { start = temp; start->next = NULL; } else { p = start; start = temp;
  • 7. start->next = p; } cout<<"Element Inserted at beginning"<>value; struct node *temp, *s; temp = create_node(value); s = start; while (s->next != NULL) { s = s->next; } temp->next = NULL; s->next = temp; cout<<"Element Inserted at last"<>value; struct node *temp, *s, *ptr; temp = create_node(value); cout<<"Enter the postion at which node to be inserted: "; cin>>pos; int i; s = start; while (s != NULL) { s = s->next; counter++; } if (pos == 1) { if (start == NULL) { start = temp; start->next = NULL; } else { ptr = start; start = temp; start->next = ptr;
  • 8. } } else if (pos > 1 && pos <= counter) { s = start; for (i = 1; i < pos; i++) { ptr = s; s = s->next; } ptr->next = temp; temp->next = s; } else { cout<<"Positon out of range"<next;s !=NULL;s = s->next) { if (ptr->info > s->info) { value = ptr->info; ptr->info = s->info; s->info = value; } } ptr = ptr->next; } } void SingleLinkedList::delete_pos() { int pos, i, counter = 0; if (start == NULL) { cout<<"List is empty"<>pos; struct node *s, *ptr; s = start; if (pos == 1)
  • 9. { start = s->next; } else { while (s != NULL) { s = s->next; counter++; } if (pos > 0 && pos <= counter) { s = start; for (i = 1;i < pos;i++) { ptr = s; s = s->next; } ptr->next = s->next; } else { cout<<"Position out of range"<>pos; cout<<"Enter the new value: "; cin>>value; struct node *s, *ptr; s = start; if (pos == 1) { start->info = value; } else { for (i = 0;i < pos - 1;i++) { if (s == NULL)
  • 10. { cout<<"There are less than "<next; } s->info = value; } cout<<"Node Updated"<>value; struct node *s; s = start; while (s != NULL) { pos++; if (s->info == value) { flag = true; cout<<"Element "<next; } if (!flag) cout<<"Element "<next == NULL) { return; } ptr1 = start; ptr2 = ptr1->next; ptr3 = ptr2->next; ptr1->next = NULL; ptr2->next = ptr1; while (ptr3 != NULL) { ptr1 = ptr2; ptr2 = ptr3; ptr3 = ptr3->next; ptr2->next = ptr1; } start = ptr2; } void SingleLinkedList::display()
  • 11. { struct node *temp; if (start == NULL) { cout<<"The List is Empty"<info<<"->"; temp = temp->next; } cout<<"NULL"<