please provide me doubly linked list all algorithms......

Recommended Answers

All 4 Replies

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.