Linked List Operations algorithm

In computer science, we use a group of nodes to represent a sequence data. It's a data structure operation. Link list is a way of storing data in a sequence and use those data easily. This allow us to pick or delete data in a specific location of list.


Linked List operation

Link List:

  1. Singly Link List 
  2. Doubly Link List
  3. Circular Link List

Link List Operations: 

  • Pseudo-code for insert at Beginning
  • Pseudo-code for insert at End
  • Pseudo-code for delete from Beginning
  • Pseudo-code for delete from End
  • Pseudo-code for insert at Kth position of the list
  • Pseudo-code for delete from Kth position of the list
  • Pseudo-code for search data in list

Singly Link List:

Singly Link List contain a data find and also a tail to point next data field or node.

Singly Link List

Doubly Link List:

 Doubly Link List contain a head, a data find and also a tail to point next data field or node.

 Doubly Link List

 Circular Link List:

In Circular Link List, the last tail point to the first nodes head. If we do like this, it's called circular linked list otherwise it's called linear or open list.

Circular Link List

 Link List Operations

1.  Pseudo-code for Insert at Beginning

Pseudo-code for Insert at Beginning
getcell(m) //here m is a new cell containing data 1
m -> data = 1
m -> link = head
head = m

2. Pseudo-code for insert at End


Pseudo-code for insert at End
getcell(m) //here m is new cell containing data 9
Pseudo-code for insert at End
while(head->link != NULL)
head = head-> link

m-> link = NULL
m->data = 8
head->link = m

3. Pseudo-code for delete from Beginning

Pseudo-code for delete from Beginning
 temp = head
head = head->link
free(temp)

 4. Pseudo-code for delete from End

 Before deletion process:

Pseudo-code for delete from End(before)
temp = head
while(head->link != NULL)
{
temp = head
head = head->link
}

Pseudo-code for delete from End(before)
temp->link = NULL
free(head)

After Deletion process:

Pseudo-code for delete from End(after deletion)

 5. Pseudo-code for insert at Kth position of the list

 
insert at Kth position of the list

getcell(m) //we will insert in pos=3

insert at Kth position of the list

pos = k
for(i=1; i<=pos-2; i++)
head = head->link

temp = head->link
head->link = m
m>link = temp

6. Pseudo-code for delete from Kth position of the list

 Before deletion process:

delete from Kth position of the list(before)

for(i=1; i<=pos-2; i++)
head = head->link
temp = head->link
delete from Kth position of the list(before)
head->link = temp->link
free(temp)

After Deletion process:

 
delete from Kth position of the list(after deletion)

 7. Pseudo-code for search data in list

 
Pseudo-code for search data in list

 let key = 7
found = false
while(head->link !=Null && found == false)
{
if(head->data == key)
found = true

else
head = head->link
}
if(found == true) //search key found
else  Not found
So, you can now try to write some code using linked list.
Happy Coding

Linked List Operations algorithm. How linked list works in programming?In computer science, we use a group of nodes to represent a sequence data. It's a data structure operation. Link list is a way of storing data in a sequence and use those data easily. This allow us to pick or delete data in a specific location of list. what is link list.