Question: / / / Singly Linked Lists #include using namespace std; template class Node { public: T Data; Node * link; } ; template class Chain
Singly Linked Lists
#include
using namespace std;
template
class Node
public:
T Data;
Node link;
;
template
class Chain
private:
Node firstlast;
int len;
public:
Chain;
~Chain;
void Insertint T;
void Deleteint T&;
bool Findint T&;
int SearchT;
void Display;
int Length return len;
bool isEmpty;
bool isFull;
;
template
Chain::Chain
first last NULL;
len;
template
bool Chain ::isEmpty
if firstNULL
return true;
else
return false;
template
int Chain::SearchT Element
Node p first;
int i;
whilep NULL
ifElement pData
return i; Succ Search
pplink;
i;
return ; Unsucc Search
template
bool Chain::Findint pos, T &Element
ifpos poslen
cout"Invalid Position....";
return false;
Node pfirst;
forint i;ilink;
Element pData;
return true;
template
void Chain::Insertint pos,T Element
Node temp;
temp new Node;
tempData Element;
templinkNULL;
iflen
first last temp;
else
ifpos
templink first;
first temp;
else ifpos len
lastlink temp;
last temp;
else
Node pfirst;
forint i;ipos;i
pplink;
templink plink;
plink temp;
len;
template
void Chain::Deleteint pos, T &Element
Node pq;
pqfirst;
iflen
cout"Linked List is Empty...";
return;
ifpos
firstfirstlink;
else ifposlen
forint i;ipos;i
pplink;
plinkNULL;
lastp;
else
forint i;ipos;i
pplink;
qplink;
plink qlink;
Element qData;
delete q;
len;
template
void Chain::Display
Node p first;
whilep NULL
cout";
pplink;
template
Chain::~Chain
Node p first;
whilep NULL
first firstlink;
cout
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
