Question: / / singly _ linked _ list.cpp : Defines the entry point for the console application. / / #include stdafx.h #include #include using namespace
singlylinkedlist.cpp : Defines the entry point for the console application.
#include "stdafx.h
#include
#include
using namespace std;
struct Node
int data;
string x;
Node next; it will contain pointer to the next node in the list.
;
class LinkedList
private:
Node head; pointing to the first node in the list
public:
LinkedList
headnullptr;
void insertint data, string b
Node newnode new Node;
newnodedata data;
newnodex b;
newnodenext nullptr;
ifheadnullptr
head newnode;
else
Node temp head;
whiletempnext!nullptr
temp tempnext;
tempnext newnode; this points to last current node in list
void display
Node temp head;
whiletempnullptr
coutdatavalue
head tempnext;
delete temp; to free the memory
whiletempnullptr && tempdata!value
prev temp;
temp tempnext;
iftempnullptrif list is empty
cout"Item is not in the list";
return;
prevnext tempnext;
delete temp;
;
int main
LinkedList l;
linsert "Ahmed";
linsert "Habib";
linsert "Ali";
linsert "Moeen";
linsert "sohaib";
linsert "Abdul Rafeh";
cout"Below is the inserted list of Items : ;
ldisplay;
cout
You have to implement the search data and update data function in the sample singly linked list source code.
Implement the complete doubly linked list, implement the insert node, delete node, update node data, search data, display data from doubly linked list.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
