5
Contributors
4
Replies
7
Views
6 Years
Discussion Span
Last Post by antechindia
0

There are two function use in double link list Insert or delete. both algorithems are following
INSERT:-
1.if(List=Full)Then return=0 end if
Else
2.found = Search list(list,pPre,pSucc,datain)
3.if (not found)then Allocate(pnew)
pNew->data=datain
4.if (pPre is null)
1.pNew ->back=NULL
2.pnew ->fore = list.head
3.list.head=pNew else
1.pNew-> fore = pPre->fore
2.pNew ->back=pPre end if
6.if (pPre ->fore NULL) then list.rear=pNew else
1.pSucc->back=pNew
8.end if
9.pPre->fore=pNew
10.list.coount=list.count+1
11.return(1)
5.endif
6.return(2)
END algorithm.

DELETE:-
1.if(pdlt NULL)
1.abort (impossible condition in delete double)
2.end if
3.list.count=list.count+1
4.if(pDlt->back ot NULL)
1.pPred=pDlt->back
2.pPred->fore=pDlt->fore
5.else
1.list.head=pDlt->fore
6.endif
7.if (pDlt->fore not NULL)
1.pSucc=pDlt->fore
2.pSucc->back=pDlt->back
8.else
1.list.rear=pDlt->back
9.end if
10.recycle(pDlt)
11.return
End algorithm

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.