SlideShare a Scribd company logo
1 of 5
Download to read offline
take the following code and give details of what each line of code is doing
#include
#include
#include
using namespace std;
/*
* Node Declaration
*/
struct node
{
int info;
struct node *next;
}*start;
/*
* Class Declaration
*/
class single_llist
{
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();
single_llist()
{
start = NULL;
}
};
/*
* Main :contains menu
*/
main()
{
int choice, nodes, element, position, i;
single_llist sl;
start = NULL;
while (1)
{
cout<>choice;
switch(choice)
{
case 1:
cout<<"Inserting Node at Beginning: "<info = value;
temp->next = NULL;
return temp;
}
}
/*
* Inserting element in beginning
*/
void single_llist::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"<info<<"->";
temp = temp->next;
}
cout<<"NULL"<
Solution
ANSWER ::
ASSMUING THE TOTAL LINE IN CODE ARE 158*(INCLUDING COMMENTS)
SO...
PROGRAM STARTS WITH SPECIFING HEADER FILES AND GLOBAL VARIABLE
DECLARATION
THEN Node Declaration USING STRUCTURES,
THEN WE WANT TO DECLARE THE CLASS USING SINGLE LINKED LIST AND THE
PROTOTYPE IS PUBLIC
IN THE PUBLIC WE WANT TO CREATE THE NODE AS INTEGER DATATYPE
THE NODE CONSIST OF insert_begin();
insert_pos();-> INDICATES THE CURRENT POSSITION
insert_last();->INSERT AT LAST
delete_pos();->TO DELETE THE NUMBER AT CURRENT POSITION
sort();->START THE SORTING
search();->USED TO SEARCH
update();->UPDATE THE NODE
reverse();->REVERSE NUMBERS
display();->TO DISPLAY THE NODE
single_llist()->FIFO
WE ARE STARTING TAKING NULL VALUE
AND THEN TAKE USER DEFIND FUNCTION MAIN()
CREATE THE DATATYPES choice, nodes, element, position, i
OBJECT CREATION OF SLL IS SL
USING WHILE LOOP THE NODE INSERT AT THE BEGINING OR ENDING STAGE
WE ARE USING SWITCH CASES TO PERFORM SLL ON NODE
NODE CREATION AS
node *single_llist::create_node(int value)
ALSO DECLARE THE TEMP IS TAKEN AS NULL VALUE
INSERT THE ELEMENT AT THE BEGINING
USING IF CONDITION WE CAN INSERT THE NODE AT THE BEGINING
struct node *temp, *p;
temp = create_node(value);
if (start == NULL)
{
start = temp;
start->next = NULL;
}
else
{
p = start;
start = temp;
start->next = p;
AND THEN INSERT THE NODE AT THE LAST
struct node *temp, *s;
temp = create_node(value);
s = start;
while (s->next != NULL)
{
s = s->next;
}
temp->next = NULL;
s->next = temp;
USING WHILE LOOP WE ARE INSERTING THE NODE AT LAST
USING THIS BELLOW CODE WE CAN SEARCH THE ELEMENTS IN THE NODE
struct node *temp;
if (start == NULL)
{
cout<<"The List is Empty"<info<<"->";
temp = temp->next;
}
cout<<"NULL"<

More Related Content

Similar to take the following code and give details of what each line of code i.pdf

C++ Program to Implement Singly Linked List #includei.pdf
  C++ Program to Implement Singly Linked List  #includei.pdf  C++ Program to Implement Singly Linked List  #includei.pdf
C++ Program to Implement Singly Linked List #includei.pdf
anupambedcovers
 
AnswerNote LinkedList.cpp is written and driver program main.cpp.pdf
AnswerNote LinkedList.cpp is written and driver program main.cpp.pdfAnswerNote LinkedList.cpp is written and driver program main.cpp.pdf
AnswerNote LinkedList.cpp is written and driver program main.cpp.pdf
anwarsadath111
 
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
 
C++ Program to Implement Doubly Linked List #includei.pdf
  C++ Program to Implement Doubly Linked List  #includei.pdf  C++ Program to Implement Doubly Linked List  #includei.pdf
C++ Program to Implement Doubly Linked List #includei.pdf
Lalkamal2
 
ItemNodeh include ltiostreamgt include ltstring.pdf
ItemNodeh    include ltiostreamgt include ltstring.pdfItemNodeh    include ltiostreamgt include ltstring.pdf
ItemNodeh include ltiostreamgt include ltstring.pdf
acmefit
 
How do you stop infinite loop Because I believe that it is making a.pdf
How do you stop infinite loop Because I believe that it is making a.pdfHow do you stop infinite loop Because I believe that it is making a.pdf
How do you stop infinite loop Because I believe that it is making a.pdf
feelinggift
 
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
 
C++ Program to Implement Singly Linked List #includeiostream.pdf
 C++ Program to Implement Singly Linked List #includeiostream.pdf C++ Program to Implement Singly Linked List #includeiostream.pdf
C++ Program to Implement Singly Linked List #includeiostream.pdf
angelsfashion1
 
1) C++ Program to Implement Singly Linked List #inclu.pdf
1)  C++ Program to Implement Singly Linked List  #inclu.pdf1)  C++ Program to Implement Singly Linked List  #inclu.pdf
1) C++ Program to Implement Singly Linked List #inclu.pdf
ankitmobileshop235
 
implement the ListLinked ADT (the declaration is given in ListLinked.pdf
implement the ListLinked ADT (the declaration is given in ListLinked.pdfimplement the ListLinked ADT (the declaration is given in ListLinked.pdf
implement the ListLinked ADT (the declaration is given in ListLinked.pdf
FOREVERPRODUCTCHD
 
DATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDY
DATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDYDATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDY
DATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDY
Malikireddy Bramhananda Reddy
 
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
 
Doublylinklist
DoublylinklistDoublylinklist
Doublylinklist
ritu1806
 

Similar to take the following code and give details of what each line of code i.pdf (20)

C program to insert a node in doubly linked list
C program to insert a node in doubly linked listC program to insert a node in doubly linked list
C program to insert a node in doubly linked list
 
C++ Program to Implement Singly Linked List #includei.pdf
  C++ Program to Implement Singly Linked List  #includei.pdf  C++ Program to Implement Singly Linked List  #includei.pdf
C++ Program to Implement Singly Linked List #includei.pdf
 
AnswerNote LinkedList.cpp is written and driver program main.cpp.pdf
AnswerNote LinkedList.cpp is written and driver program main.cpp.pdfAnswerNote LinkedList.cpp is written and driver program main.cpp.pdf
AnswerNote LinkedList.cpp is written and driver program main.cpp.pdf
 
DSA(1).pptx
DSA(1).pptxDSA(1).pptx
DSA(1).pptx
 
Consider L = {a^nb^2nc^P p 0}. Prove L is not a context-free langu.pdf
Consider L = {a^nb^2nc^P  p  0}. Prove L is not a context-free langu.pdfConsider L = {a^nb^2nc^P  p  0}. Prove L is not a context-free langu.pdf
Consider L = {a^nb^2nc^P p 0}. Prove L is not a context-free langu.pdf
 
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
 
C++ Program to Implement Doubly Linked List #includei.pdf
  C++ Program to Implement Doubly Linked List  #includei.pdf  C++ Program to Implement Doubly Linked List  #includei.pdf
C++ Program to Implement Doubly Linked List #includei.pdf
 
ItemNodeh include ltiostreamgt include ltstring.pdf
ItemNodeh    include ltiostreamgt include ltstring.pdfItemNodeh    include ltiostreamgt include ltstring.pdf
ItemNodeh include ltiostreamgt include ltstring.pdf
 
Linked lists
Linked listsLinked lists
Linked lists
 
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
 
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
 
Ds 2 cycle
Ds 2 cycleDs 2 cycle
Ds 2 cycle
 
C++ Program to Implement Singly Linked List #includeiostream.pdf
 C++ Program to Implement Singly Linked List #includeiostream.pdf C++ Program to Implement Singly Linked List #includeiostream.pdf
C++ Program to Implement Singly Linked List #includeiostream.pdf
 
1) C++ Program to Implement Singly Linked List #inclu.pdf
1)  C++ Program to Implement Singly Linked List  #inclu.pdf1)  C++ Program to Implement Singly Linked List  #inclu.pdf
1) C++ Program to Implement Singly Linked List #inclu.pdf
 
Lab-2.4 101.pdf
Lab-2.4 101.pdfLab-2.4 101.pdf
Lab-2.4 101.pdf
 
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
 
DATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDY
DATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDYDATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDY
DATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDY
 
data structure3.pptx
data structure3.pptxdata structure3.pptx
data structure3.pptx
 
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
 
Doublylinklist
DoublylinklistDoublylinklist
Doublylinklist
 

More from fastechsrv

Tonya and Lydia are two senior nursing students assigned to work in .pdf
Tonya and Lydia are two senior nursing students assigned to work in .pdfTonya and Lydia are two senior nursing students assigned to work in .pdf
Tonya and Lydia are two senior nursing students assigned to work in .pdf
fastechsrv
 
The Ad Hoc network shown below (including node Q) is currently operat.pdf
The Ad Hoc network shown below (including node Q) is currently operat.pdfThe Ad Hoc network shown below (including node Q) is currently operat.pdf
The Ad Hoc network shown below (including node Q) is currently operat.pdf
fastechsrv
 
Need help coding MorseCode in JavaCreate Class MorseCodeClient. T.pdf
Need help coding MorseCode in JavaCreate Class MorseCodeClient. T.pdfNeed help coding MorseCode in JavaCreate Class MorseCodeClient. T.pdf
Need help coding MorseCode in JavaCreate Class MorseCodeClient. T.pdf
fastechsrv
 
Match the description with the appropriate term. Where more than one .pdf
Match the description with the appropriate term. Where more than one .pdfMatch the description with the appropriate term. Where more than one .pdf
Match the description with the appropriate term. Where more than one .pdf
fastechsrv
 

More from fastechsrv (20)

What is the purpose of performing a dark reaction Explain why it is.pdf
What is the purpose of performing a dark reaction Explain why it is.pdfWhat is the purpose of performing a dark reaction Explain why it is.pdf
What is the purpose of performing a dark reaction Explain why it is.pdf
 
What is a tissue _____ What are some identifying features of merist.pdf
What is a tissue _____  What are some identifying features of merist.pdfWhat is a tissue _____  What are some identifying features of merist.pdf
What is a tissue _____ What are some identifying features of merist.pdf
 
Tonya and Lydia are two senior nursing students assigned to work in .pdf
Tonya and Lydia are two senior nursing students assigned to work in .pdfTonya and Lydia are two senior nursing students assigned to work in .pdf
Tonya and Lydia are two senior nursing students assigned to work in .pdf
 
This figure shows the stress-strain curve for a polymer. The followi.pdf
This figure shows the stress-strain curve for a polymer. The followi.pdfThis figure shows the stress-strain curve for a polymer. The followi.pdf
This figure shows the stress-strain curve for a polymer. The followi.pdf
 
There are 6 holes in a wall. A mouse is in one hole I dont know wh.pdf
There are 6 holes in a wall.  A mouse is in one hole I dont know wh.pdfThere are 6 holes in a wall.  A mouse is in one hole I dont know wh.pdf
There are 6 holes in a wall. A mouse is in one hole I dont know wh.pdf
 
The identity below was verified incorrectly. In which line was an err.pdf
The identity below was verified incorrectly. In which line was an err.pdfThe identity below was verified incorrectly. In which line was an err.pdf
The identity below was verified incorrectly. In which line was an err.pdf
 
The FED is both centralized and decentralized in its structure. .pdf
The FED is both centralized and decentralized in its structure. .pdfThe FED is both centralized and decentralized in its structure. .pdf
The FED is both centralized and decentralized in its structure. .pdf
 
The diameter of the Milky Way disc is approximately 9x10^20 meters. .pdf
The diameter of the Milky Way disc is approximately 9x10^20 meters. .pdfThe diameter of the Milky Way disc is approximately 9x10^20 meters. .pdf
The diameter of the Milky Way disc is approximately 9x10^20 meters. .pdf
 
The Ad Hoc network shown below (including node Q) is currently operat.pdf
The Ad Hoc network shown below (including node Q) is currently operat.pdfThe Ad Hoc network shown below (including node Q) is currently operat.pdf
The Ad Hoc network shown below (including node Q) is currently operat.pdf
 
RNA is important for all of the following reasons EXCEPT most RNA .pdf
RNA is important for all of the following reasons EXCEPT  most RNA .pdfRNA is important for all of the following reasons EXCEPT  most RNA .pdf
RNA is important for all of the following reasons EXCEPT most RNA .pdf
 
Patient A got IV (Intravenous) fluid at the hospital that turned out .pdf
Patient A got IV (Intravenous) fluid at the hospital that turned out .pdfPatient A got IV (Intravenous) fluid at the hospital that turned out .pdf
Patient A got IV (Intravenous) fluid at the hospital that turned out .pdf
 
Need help coding MorseCode in JavaCreate Class MorseCodeClient. T.pdf
Need help coding MorseCode in JavaCreate Class MorseCodeClient. T.pdfNeed help coding MorseCode in JavaCreate Class MorseCodeClient. T.pdf
Need help coding MorseCode in JavaCreate Class MorseCodeClient. T.pdf
 
Novotny et al. The authors of the paper Why are there so many speci.pdf
Novotny et al. The authors of the paper Why are there so many speci.pdfNovotny et al. The authors of the paper Why are there so many speci.pdf
Novotny et al. The authors of the paper Why are there so many speci.pdf
 
Match the description with the appropriate term. Where more than one .pdf
Match the description with the appropriate term. Where more than one .pdfMatch the description with the appropriate term. Where more than one .pdf
Match the description with the appropriate term. Where more than one .pdf
 
How should globalization be viewed as a four dimensional concept.pdf
How should globalization be viewed as a four dimensional concept.pdfHow should globalization be viewed as a four dimensional concept.pdf
How should globalization be viewed as a four dimensional concept.pdf
 
I want the show the works step by step for Aand B Autism is a seriou.pdf
I want the show the works step by step for Aand B Autism is a seriou.pdfI want the show the works step by step for Aand B Autism is a seriou.pdf
I want the show the works step by step for Aand B Autism is a seriou.pdf
 
If only one strand of the DNA molecule is transcribed for a particul.pdf
If only one strand of the DNA molecule is transcribed for a particul.pdfIf only one strand of the DNA molecule is transcribed for a particul.pdf
If only one strand of the DNA molecule is transcribed for a particul.pdf
 
How do each of the factors listed in (1) affect the diffusion of sol.pdf
How do each of the factors listed in (1) affect the diffusion of sol.pdfHow do each of the factors listed in (1) affect the diffusion of sol.pdf
How do each of the factors listed in (1) affect the diffusion of sol.pdf
 
find the domain of the function f (x)= 2x3 x8SolutionNumerat.pdf
find the domain of the function f (x)= 2x3 x8SolutionNumerat.pdffind the domain of the function f (x)= 2x3 x8SolutionNumerat.pdf
find the domain of the function f (x)= 2x3 x8SolutionNumerat.pdf
 
Explain a) advantage of dispersing seeds, andexplain b) two (2) neat.pdf
Explain a) advantage of dispersing seeds, andexplain b) two (2) neat.pdfExplain a) advantage of dispersing seeds, andexplain b) two (2) neat.pdf
Explain a) advantage of dispersing seeds, andexplain b) two (2) neat.pdf
 

Recently uploaded

Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
ciinovamais
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
QucHHunhnh
 

Recently uploaded (20)

On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptx
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 

take the following code and give details of what each line of code i.pdf

  • 1. take the following code and give details of what each line of code is doing #include #include #include using namespace std; /* * Node Declaration */ struct node { int info; struct node *next; }*start; /* * Class Declaration */ class single_llist { 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(); single_llist() { start = NULL; } };
  • 2. /* * Main :contains menu */ main() { int choice, nodes, element, position, i; single_llist sl; start = NULL; while (1) { cout<>choice; switch(choice) { case 1: cout<<"Inserting Node at Beginning: "<info = value; temp->next = NULL; return temp; } } /* * Inserting element in beginning */ void single_llist::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; }
  • 3. 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"<info<<"->"; temp = temp->next; } cout<<"NULL"< Solution ANSWER :: ASSMUING THE TOTAL LINE IN CODE ARE 158*(INCLUDING COMMENTS) SO... PROGRAM STARTS WITH SPECIFING HEADER FILES AND GLOBAL VARIABLE DECLARATION THEN Node Declaration USING STRUCTURES, THEN WE WANT TO DECLARE THE CLASS USING SINGLE LINKED LIST AND THE PROTOTYPE IS PUBLIC IN THE PUBLIC WE WANT TO CREATE THE NODE AS INTEGER DATATYPE THE NODE CONSIST OF insert_begin(); insert_pos();-> INDICATES THE CURRENT POSSITION insert_last();->INSERT AT LAST delete_pos();->TO DELETE THE NUMBER AT CURRENT POSITION sort();->START THE SORTING
  • 4. search();->USED TO SEARCH update();->UPDATE THE NODE reverse();->REVERSE NUMBERS display();->TO DISPLAY THE NODE single_llist()->FIFO WE ARE STARTING TAKING NULL VALUE AND THEN TAKE USER DEFIND FUNCTION MAIN() CREATE THE DATATYPES choice, nodes, element, position, i OBJECT CREATION OF SLL IS SL USING WHILE LOOP THE NODE INSERT AT THE BEGINING OR ENDING STAGE WE ARE USING SWITCH CASES TO PERFORM SLL ON NODE NODE CREATION AS node *single_llist::create_node(int value) ALSO DECLARE THE TEMP IS TAKEN AS NULL VALUE INSERT THE ELEMENT AT THE BEGINING USING IF CONDITION WE CAN INSERT THE NODE AT THE BEGINING struct node *temp, *p; temp = create_node(value); if (start == NULL) { start = temp; start->next = NULL; } else { p = start; start = temp; start->next = p; AND THEN INSERT THE NODE AT THE LAST struct node *temp, *s; temp = create_node(value); s = start; while (s->next != NULL) { s = s->next; }
  • 5. temp->next = NULL; s->next = temp; USING WHILE LOOP WE ARE INSERTING THE NODE AT LAST USING THIS BELLOW CODE WE CAN SEARCH THE ELEMENTS IN THE NODE struct node *temp; if (start == NULL) { cout<<"The List is Empty"<info<<"->"; temp = temp->next; } cout<<"NULL"<