ProgrammingHard

A hash chain delete on a singly linked bucket list is written with a pointer-to-pointer. Which description is the advantage?

  1. A. It makes deletion O(1) without any search
  2. B. It removes all matches in one step
  3. C. It removes the first match whether it is the head or not, with one code path and no special case
  4. D. It avoids the need for malloc on insertion

Correct answer: C. It removes the first match whether it is the head or not, with one code path and no special case

Walking with a pointer to the link you may change handles both the head and inner nodes with the same statement. It still searches the chain, so deletion is O(length).

More C Programming questions

Exams that ask this topic