Basic Implementation of Singly Linked List
Various implementation using singly linked list like insertion, deletion etc.
Node Structure
struct node
{
int data;
struct node *next;
};
node *head = NULL;Finding the length of the linked list
int getLen()
{
node *p = head;
int s = 0;
while (p != NULL)
{
s = s + 1;
p = p->next;
/* code */
}
return s;
}Insertion in a Linked List
Insertion in a linked list takes O(1) time.
Insertion at any random position of a Linked list
Deletion in a Linked list
Deletion at any random position of a Linked list
Displaying elements of the Linked List
Last updated
Was this helpful?