Bloomberg L.P. Interview Question: There is a linked list, only ... | Glassdoor

Interview Question

Financial Software Developer Interview New York, NY

There is a linked list, only given the pointer of one node

  , how to delete that node in the linked list.
Tags:
technical, algorithm
Answer

Interview Answer

3 Answers

0

I guess it refers to a single linked list.

iterate unti item->next = toDelete, item->next = toDelete->next, delete(toDelete).

ektor on Sep 12, 2012
4

void deleteNode(struct node *node_ptr)
{
   struct node *temp = node_ptr->next;
   node_ptr->data = temp->data;
   node_ptr->next = temp->next;
   free(temp);
}

Anonymous on Oct 5, 2012
0

First answer I dont think is right, since we can only iterate through the nodes after the given node, not from beginning,

Anonymous on Feb 19, 2016

Add Answers or Comments

To comment on this, Sign In or Sign Up.