ITPEC FE Subject B April 2026 Question 10

Source exam: ITPEC FE Subject B April 2026Topic: Linked List

ITPEC FE Subject B April 2026 — Question 10 of 20

A is head1.val ≤ head2.val, B is head1.next and C is head2.next.

The merge takes the smaller of the two current heads and recurses on the rest:

  • Blank A — when head1.val is the smaller (or equal), head1 becomes the result node
  • Blank B — that node is now consumed, so the recursive call continues with head1.next while head2 stays where it is
  • Blank C — the mirror case: head2 was taken, so the call advances head2.next and leaves head1 untouched

Only the list whose element was just used may advance; the other must be reconsidered next time.

Answer (c)

Why not others:
- (a) and (b) — test head1.next is undefined, which asks about list length rather than order, so the output is not sorted

- (e) and (f) — take head1 only when the values are equal, sending every unequal pair down the head2 branch

- (g) and (h) — use , which merges into descending order

- (b), (d), (f) and (h) — advance the list that was not consumed, dropping elements from one list and repeating them from the other

Key rule: In a recursive merge exactly one pointer moves per call, and it is the one whose value was just placed in the result.

AI-generated — may contain errors

The original exam layout is preserved in the image so diagrams, formulas, tables, and code remain accurate.

This question comes from an official ITPEC past paper. ITPEC Practice is an independent study tool and is not affiliated with ITPEC. See the official FE past-paper collection or Report an issue.