I have written code for deletion in the linked list but it is running in an infinite loop.
Identify the error please
I corrected your function. Please check it.
can you please mark where have you corrected the code
Check your deletehead function.
we have just pointed the pointer part to the next node but head is not deleted dynamically won’t it lead to memory leakage
coz we still have head in our memory
No it won’t lead to any memory leakage. This is how we delete any node in our linked list. And the function returns the new head. So, its fine.
1 Like
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.