116k views
4 votes
How to add a node to linked list

User Jyotsna
by
8.2k points

1 Answer

4 votes

Answer:

Traverse the Linked list upto position-1 nodes.

Once all the position-1 nodes are traversed, allocate memory and the given data to the new node.

Point the next pointer of the new node to the next of current node.

Step-by-step explanation: