https://ide.codingblocks.com/s/56166 please tell me what wrong with my code
Linklist delete at middle
- You haven’t handled the case when the head node should be deleted i.e when p = 0;
- second ++ - in case of linked list pointers are incremented as second = second ->next
- temp->next node should be deleted - temp node is the node previous to second
so take node* waste = temp->next ;
temp->next = second
delete waste ;
https://ide.codingblocks.com/s/56166 please see this code this gives output as
input
delete(head,5);
1 2 3 4 5 6 7 8 9 10
1 0 3 4 6 7 8 9 10
please check
node * waste
is basically storing the node which you want to delete , and freeing the memory from heap , so the code should be like this https://ide.codingblocks.com/s/56192