class LinkListNode
{
friend class LinkList;
private:
int data;
LinkListNode *llink, * rlink;
};
class LinkList
{
private:
LinkListNode *start;
};
// Basic form of deleting node from LinkList
void delete ( int x , node * start )
{
node *p ;
p = start → rlink ;
while ( p && p →data < x )
{
p = p → rlink ;
if ( p = = Null | | p → data > x )
return " There isn't any data " ;
( p →llink ) → rlink = p → rlink ;
( p →rlink ) → llink = p → llink ;
delete ( p ) ;
}
}
First Fuction:
// deleting node which are at the middle of the Doubly LinkList (Second Type: first node and last node have link between together.)
void LinkList::Delete(ListLink *x)
{
if(x==start)
cout<<" There is no data to delete ."
else
{
x → llink → rlink = x → rlink;
x → rlink → llink = x → llink;
delete x;
}
}
Second Function:
// deleting node which are at the end of the Doubly LinkList(Second type)
void LinkList::Delete(ListLink *x)
{
if(x==start)
cout<<"There is no data to delete."
else
{
x → llink = x → rlink;
x → rlink → llink = x → llink;
delete x;
}
}
Third Function:
// deleting node which are at the beginning of the Doubly LinkList(Second Type)
void LinkList::Delete(ListLink *x)
{
if(x==start)
cout<<"There is no data to delete."
else
{
x → rlink → llink = x → llink;
x → llink = x → rlink;
delete x;
}
}
Forth Function:
// deleting node which are at the Beginning of the Doubly LinkList(First Type: First node and last node doesn’t have any link between them.)
void LinkList::Delete(ListLink *x)
{
if(x==start)
cout<<"There is no data to delete."
else
{
x → llink → rlink = null;
x → llink = null;
delete x;
}
Fifth Function:
// deleting node which are at the end of the Doubly LinkList (First type)
void LinkList::Delete(ListLink *x)
{
if(x==start)
cout<<"There is no data to delete."
else
{
x → rlink = null;
x → rlink → llink = null;
delete x;
}
Sixth Function:
Note: The Sixth Function and First Function are the same.
void LinkList::Delete(ListLink *x)
{
if(x==start)
cout<<" There is no data to delete ."
else
{
x → llink → rlink = x → rlink;
x → rlink → llink = x → llink;
delete x;
}