ITPEC FE Morning April 2020 Question 5
ITPEC FE Morning April 2020 — Question 5 of 80
Linked list insertion using arrays — insert element between 3rd and 4th nodes.
Trace the list using next[0] as head pointer:
- •
next[0] = 1→ head is index1 - •
1(A) →5(E) →3(D) →7(G) →2(B) →0(end)
Insert "H" (at box[8]) between 3rd element (D, index 3) and 4th element (G, index 7):
- •Set
next[3] = 8(D now points to H) - •Set
next[8] = 7(H points to G)
Answer: next[8] = 7 → (c)
Why not others:
- (a) 3 — would point H back to D (the predecessor)
- (b) 5 — index of E, unrelated to the insertion point
- (d) 8 — would create a self-loop
Key rule: When inserting node X between nodes A and B in a linked list: set next[A] = X, then next[X] = B (old value of next[A]).
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.