int total = 0, mid = 0;
If (head->next)
delelte_mid_node(head, &total, &mid);
else // If only one node in list then no need to call function "delelte_mid_node"
head = NULL;
void deleltemidnode(node *ptr, int *totalnode, int *mid)
{
if (ptr == NULL)
{
*totalnode = *totalnode - 1;
if (*totalnode % 2 == 0)
printf("\nNode is even in list\n");
return;
}
*totalnode = *totalnode + 1;
deleltemidnode(ptr->next, totalnode, mid);
if(*totalnode %2 != 0)
{
*mid = *mid + 1;
if(*mid == ((*totalnode + 2) / 2))
{
ptr->next = ptr->next->next;
}
}
}
Logic is right.
But here is memory leak because i did not free the memory of deleted node.