Friday, 25 January 2013

Algorithm for Delete a node at a position of a Linked List

ALGORITHM NAME: DELETE_POSITION_LL(&START,P)


1.start
2.temp=start
3.prev=start
4.if start=NULL
                1.print Linkedlist id Empty
5.Else
                1.c=1
                2.while c<p,do
                                1.prev=temp
                                2.temp=temp->link
                                3.if temp=NULL
                                                1.Print out of range
                                4.Else
                                                1.c=c+1
                                5.End if
                3.End While
                4.If temp=prev
                                1.start=start->link
                5.End if
                6.prev->link=temp->data
                7.Delete node pointed by temp
                8.stop
6.End if
7.stop

No comments:

Post a Comment