Given only a pointer to the node to be deleted , how do we delete the node in the linked list…?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The question is too ambiguous, and is likely that way for a reason (e.g. to spawn a conversation instead of test your actual knowledge of the data structure). They are likely expecting you to ask “Is this a doubly linked list or a singly linked list?” If it is a doubly linked list, its a simple matter:
If it is a singly linked list, you must have the head node so you can find the previous node in the list. So they are likely expecting you to ask if you have a pointer to the head node. The pseudo-code would then be:
Alternatively, if you can modify the list (without the head node):