Link List Algorithm
Link List Algorithm
Algorithms:
[ This algorithm implement the single linked list and do insertion at beginning, last, after a given value and deletion
from the beginning, last ,containing the certain value. Where ‘header’ is the pointer to the header node and ‘key’ is
the data content of the node that to be inserted and deleted]
Insert at beginning ( )
Beginning
Steps
1. [initialization]
3. else
i. new→link = header→link
ii new→data= x
[ end of if ]
4. stop
Insert at end ( )
Beginning
Steps
1. [ initialization ]
new := creat_node(node )
2. if( new = NULL )
ii go to step 8
[ end of while ]
6. new→data := x
7. [ end of if ]
8. stop
Beginning
Steps
1. [initialization]
ii go to step 8
[ end of if ]
3. else
[ end of while ]
6. else
I new→link = ptr→link
Ii new→data = x
7. [end of if ]
8. stop
Beginning
Steps
1. [initialization]
ii. go to step 5
3. else
i. ptr1 = ptr→link
[end of if ]
4. free (ptr)
5. stop
Beginning
Steps
1. [initialization]
ii. go to step 5
3. else
[end of while ]
[end of if ]
4. free (ptr)
5. stop
Delete after the given value ( )
Beginning
Steps
1. [ initialization]
ii. else
b. free (ptr)
c. goto step 5
[endof if ]
[end of while ]
[end of if ]
5. stop
Double link list Algorithm:
Algorithms:
[ This algorithm implement the double linked list and do insertion at beginning, last, after a given value and
deletion from the beginning, last ,containing the certain value. Where ‘header’ is the pointer to the header node and
‘key’ is the data content of the node that to be inserted and deleted]
Insert at beginning ( )
Beginning
Steps
1. [initialization]
v new →data = x
3. else
[ end of if ]
4. stop
Insert at end ( )
Beginning
steps
1. [ initialization ]
Set ptr := header
[ end of while ]
3. new := creat_node(NODE)
Iv new →data = x
5. else
[ end of if ]
6. stop
Insert after value ( )
Beginning
Steps
1. [initialization]
[ end of while ]
ii. go to step 7
[ end of if ]
6. else
vi ptr = new
[ end of if ]
7. stop
Beginning
Steps
1. [ initialization ]
ii. go to step 5
3. else
i. ptr1 = ptr→Rlink
[ end of if ]
Iv return node(ptr)
[end of if ]
4. stop
Beginning
Steps
1. [initialization]
ii. go to step 4
3. else
[end of if ]
4. stop
Beginning
Steps
1. [ initialization]
ii. go to step 6
[end of if ]
5. else
[ end of if ]
6. stop