linked list insertion | Insert at beginning-end-after specific node | Data Structure & Algorithms

preview_player
Показать описание
linked list insertion :

Inserting a node at beginning of linked list
1-In this case a new node is inserted before the current node
2-update the next pointer of new node, to point to the current head
4-Update head pointer to point to the new node

Inserting a node at end of linked list
1- Create the new node
2-Last nodes next pointer point to new node

Inserting a node after specific node of linked list
1-Create the new Node
2-Find the position node after which the new node is to be positioned
3-Update new node next pointer to point to position node next pointer
4-Update position node next pointer to point to new node.

Рекомендации по теме