Interview Question

Financial Software Developer Intern Interview Pittsburgh, PA

Linked list memory management: deleting a node from the

  middle of a list was easy. Next question - how to delete a node from the end of a list. Was too tired to think and realize this was a trick question.
Tags:
technical
Answer

Interview Answer

5 Answers

0

You can't, since the pointer already points to null. No way around it.

Interview Candidate on Mar 13, 2013
1

Disagree,

Instead of 1 use 2 pointers, having pointer 1 one step ahead of pointer 2, once pointer 1 points to NULL, use pointer 2 to remove the last node.

Tinus on Mar 30, 2013
0

It depends. on how the link-list is implemented.

Xiaoge Su on Jul 15, 2013
0

check node->next->next equals to null or not, then can just update node->next = null

Sashi on Oct 15, 2013
0

I guess this question makes sense only when we don't know the Head node !

Sachin on Dec 2, 2013

Add Answers or Comments

To comment on this question, Sign In with Facebook or Sign Up