Microsoft Interview Question

Remove a node from Linked list when address of same node is given

Interview Answers

Anonymous

Feb 21, 2015

public void deleteValue(double d) { Link current = first; Link previous = first; while(current != null) { if(current.dData == d) { previous.next = current.next; break; } previous = current; current = current.next; } if(current == null) { System.out.println("Value = " +d+ " not found"); } }

Anonymous

May 2, 2015

copy data and next pointer from the next node to current node