ProgrammingModerate

Which kind of list makes it O(1) to delete a node given only a pointer to that node?

  1. A. A doubly linked list, using the prev and next pointers of the node
  2. B. A singly linked list, because only next is needed
  3. C. A plain array, because elements are contiguous
  4. D. A circular buffer without links

Correct answer: A. A doubly linked list, using the prev and next pointers of the node

With prev the node can unlink itself in constant time. In a singly linked list the predecessor must be found by walking from the head.

More C Programming questions

Exams that ask this topic