ProgrammingModerate
A sorted list 1, 1, 2, 3, 3 has its duplicates removed by a loop that unlinks a node whose value equals the previous node's value. How many nodes remain?
- A. 2
- B. 4
- C. 3
- D. 5
Correct answer: C. 3
The distinct values are 1, 2 and 3, so three nodes remain after the duplicates are unlinked and freed.
More C Programming questions
- A dynamic array starts with capacity 1 and doubles whenever it is full, until its capacity is at least 10. What is the final capacity?
- A complete binary tree has levels 0 to 2 (depth 3 in this count). How many nodes does it have?
- 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…
- 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?