Please tell me logic of deleteion at the middle and deletion at particular position
Please tell me logic of delete at position and middle of linked list
@rssrivastavarohan
We can delete middle node using one traversal. The idea is to use two pointers, slow_ptr and fast_ptr. Both pointers start from head of list. When fast_ptr reaches end, slow_ptr reaches middle
(Traverse linked list using two pointers. Move one pointer by one and other pointer by two. When the fast pointer reaches end slow pointer will reach middle of the linked list.)
The additional thing is to keep track of previous of middle so that we can delete middle.
for kth node The idea is traverse the list from beginning and keep track of nodes visited after last deletion. Whenever count becomes k, delete current node and reset count as 0.