ProgrammingModerate
A chained hash bucket holds the nodes 30, 20, 10 in that order from the head. The node holding 20 is deleted and freed. How many nodes remain in the chain?
- A. 1
- B. 2
- C. 3
- D. 0
Correct answer: B. 2
Deleting one node from a chain of three leaves two. The removal of a middle node needs the predecessor's next pointer updated.
More C Programming questions
- A program makes three malloc calls and two free calls, with no other allocations. How many blocks are still allocated when the program…
- int a = calloc(4, sizeof a); int sum = 0; for (int i = 0; i < 4; i++) sum += a[i]; printf("%d", sum); What is printed?
- Which statement about calling free on a null pointer is correct in C?
- A pointer p is freed with free(p) and then set to NULL. Why is this safer than leaving it dangling?
- Which code creates a flexible structure holding n ints after a header, with a single allocation and correct size?
- A tail-insertion function takes a pointer to the head pointer, so it can work on an empty list. Which loop finds the link to change?