Académique Documents
Professionnel Documents
Culture Documents
Learn C programming, Data Structures tutorials, exercises, examples, programs, hacks, tips and tricks online. A blog for beginners
to advance their skills in programming.
Write a C program to create a singly linked list of n nodes and delete node from the middle of the linked list.
How to delete node from the middle of the singly linked list in C. Algorithm to delete middle node from singly
linked list. Steps to delete middle node from singly linked list.
Required knowledge
Basic C programming, Functions, Singly linked list, Dynamic memory allocation
End if
End for
If (toDelete != NULL) then
If (toDelete == head) then
head ← head.next
End if
prevNode.next ← toDelete.next
toDelete.next ← NULL
unalloc (toDelete)
End if
End else
End
2. Reconnect the n-1th node with the n+1th node i.e. prevNode->next = toDelete->next
(Where prevNode is n-1th node and toDelete node is the nth node and toDelete->next
is the n+1th node).
3. Free the memory occupied by the nth node i.e. toDelete node.
https://codeforwin.org/2015/09/c-program-to-delete-middle-node-of-singly-linked-list.html 2/5