Header

Thursday 5 September 2013

IGNOU BCA 3rd sem Solved Assignment - Write an algorithm for the implementation of Doubly Linked Lists

Write an algorithm for  the implementation of Doubly Linked Lists
Ans
ALGORITHM :-
INSERT:-       
1.if(full list)
1.return=0
2.end if
3.found = Search list(list,pPre,pSucc,datain)
4.if (not found)
1.Allocate(pnew)
2.pNew->data=datain
3.if (pPre is null)
1.pNew ->back=NULL
2.pnew ->fore = list.head
3.list.head=pNew
4.else
1.pNew-> fore = pPre->fore
2.pNew ->back=pPre
5.end if
6.if (pPre ->fore NULL)        
1.list.rear=pNew
7.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

No comments:

Post a Comment