Given a single Linked List and we have to delete the middle the element of the Linked List.
If the length of the linked list is odd then delete (( n+1)/2)th term of the linked list and if the list is of even length then delete the (n/2+1)th term of the liked list.
Example 1:
If we have a Linked List : 1 → 2 → 3 → 4 → 5 → 6 → 7
After deleting the middle node the linked list will be:
1 → 2 → 3 → 5 → 6 → 7
4 is the middle node
Example 2:
If we have a Linked List : 1 → 2 → 3 → 4 → 5 → 6 → 7 → 8
After deleting the middle node the linked list will be:
1 → 2 → 3 → 4 → 6 → 7 → 8
5 is the middle node
Algorithm:
To solve the problem we follow the following procedure,
C++ implementation:
Output