Linked List Operations: Insert, Traverse and Delete - Cyber Thieve

Linked List Operations

In this article you will see various liked list operations like insert delete traversing also you will learn how to implement these operations on the linked list.

There are various linked list operations that allow us to perform different actions on linked lists. For example, the insertion operation adds a new element to the linked list.


Linked List operations Data Structure

in this article you will learn topics below : 

Linked List Operations :

  • Traversal - access each element of the linked list
  • Insertion - adds a new element to the linked list
  • Deletion - removes the existing elements from link list
  • Search - find a node in the linked list
  • Sort - sort the nodes of the linked list ascending or descending order
If you don't know or read our linked list detailed article read it first LINKED LIST


Also Read Our Articles on DSA :


Node Creation :

struct node
{
int data;
struct node *next;
};
struct node *head, *ptr;
ptr = (struct node *)malloc(sizeof(struct node *));

 

Things to Remember about Linked List :

head points to the first node of the linked list
next pointer of the last node is NULL, so if the next current node is NULL, we have reached the end of the linked list.

Traverse a Linked List :

Visiting every node in the linked list.

When temp is NULL, we know that we have reached the end of the linked list so we get out of the while loop.


struct node *temp = head;
printf("\n\nList elements are - \n");
while(temp != NULL) {
  printf("%d --->",temp->data);
  temp = temp->next;
}


Insertion : 

Adding a number or node in linked list is called Insertion . Insertion can be performed at many positions on linked list. 

we can insert a element at three positions in linked list

  • At the Begining of the linked list
  • At the End of the linked list
  • insertion at any specific node 

Deletion : 

Deletion in the linked list is deleting a node . It can be deleted from various positions.
we can delete a element at three positions in linked list
  • From the Begining of the linked list
  • From the End of the linked list
  • Deletion at any specific node
Search an Element on a Linked List :

Finding a node a or element in the linked list 


Sort Elements of a Linked List :

we can sort element in the linked list by applying sorting algorithms on the linked list.

Post a Comment

0 Comments
* Please Don't Spam Here. All the Comments are Reviewed by Admin.

#buttons=(Ok, Go it!) #days=(20)

Our website uses cookies to enhance your experience. Learn More
Ok, Go it!