SA Activities
a CSE.B-Tech Student's Blog
Friday, 25 January 2013
Algorithm for Traversal of a Linked List
ALGORITHM NAME:
TRAVERSAL_LL(START)
1.start
2.temp=start
3.while temp!=NULL,do
1.Process of temp->data
2.temp=temp->link
4.End while
5.stop
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
Algorithm for Delete a node at the End of a Linked List
ALGORITHM NAME:
DELETE_BEGIN_LL(&START)
1.start
2.temp=&start
3.prev=&start
4.If start=NULL
1.Print Linkedlist is Empty
5.Else
1.while temp->link!=NULL,do
1.prev=temp
2.temp=temp->link
2.End while
3.If temp=prev
1.start=NULL
4.else
1.prev->link=NULL
2.Delete node pointed by temp
5.End if
6.End if
7.stop
Algorithm for Delete a node at the Beginning of a Linked List
ALGORITHM NAME:
DELETE_BEGIN_LL(&START)
1.start
2.If start=NULL
1.Print Linkedlist is Empty
3.Else
1.temp=start
2.start=start->link
3.Remove node pointed by temp
4.End if
5.stop
Algorithm for Insert a node at a Position of a Linked List
ALGORITHM NAME:
INSERT_BEGIN_LL(START,D)
1.start
2.Create a node and store its starting address to temp
3.if temp=NULL
1.Print insertion is not possible
2.Exit
4.End if
5.temp->data=d
6.temp->link=NULL
7.If p=1
1.temp->link=start
2.start=temp
3.Exit
8.End if
9.If start=NULL
1.Print Insertion is not Possible
2.Exit
10.end if
11.c=1
12.e=start
13.while c<p-1
1.e=e->link
2.c=c+1
3.If e=NULL
1.Print Out of Range
2.Exit
4.end if
14.End while
15.temp->link=e->link
16.e->link=temp
17.stop
Algorithm for Insert a node at the End of a Linked List
ALGORITHM NAME:
INSERT_BEGIN_LL(START,D)
1.start
2.Create a node and store its starting address to temp
3.If temp=NULL
1.print Insertion is not Possible
2.Exit
4.End if
5.temp->data=d
6.temp->link=NULL
7.if strat=NULL
1.start=NULL
2.Exit
8.End if
9.e=start
10.while e->link!=NULL,do
1.e=e->link
11.End while
12.e->link=temp
13.stop
Wednesday, 23 January 2013
Algorithm for Insert a node at the Beginning of a Linked List
algorithm name:
insert_begin_ll(&start,d)
1.start
2.Create a node and store its starting address to temp
3.If temp=NULL
1.print Insertion is not possible
2.Exit
4.End if
5.temp->data=d
6.temp->link=NULL
7.temp->link=start
8.start=temp
9.stop
Newer Posts
Home
Subscribe to:
Comments (Atom)