IPA FE Subject A 2023 Question 2
A question IPA Japan published in 令和5年度 基本情報技術者試験 科目A 公開問題 問2, translated into English. ITPEC is based on the same exams.
Same question on ITPEC: Oct 2025 Q5
The table below shows the data in a list structure that has bidirectional pointers. In this table, a new Employee G is to be inserted between Employee A and Employee K. Which of the following contains only the pointers (among a through f) whose values change after the insertion?
Table
Table after the addition
Explanation
A's NextPointer and K's PreviousPointer (a and f) — only the two links between A and K must now point to G.
Following NextPointer from the node whose PreviousPointer is 0 gives the order A (100) → K (300) → T (200). G (400) goes between A and K:
- •a, A's NextPointer: 300 → 400, because A is now followed by G
- •f, K's PreviousPointer: 100 → 400, because K is now preceded by G
- •b, A's PreviousPointer, stays 0: A is still the first node
- •e, K's NextPointer, stays 200: K is still followed by T
- •c and d, T's pointers, stay 0 and 300: nothing next to T changed
- •G's own pointers are newly set: x = 300, y = 100
Answer (c)
Why not others:
- •(a) — also changes b and e, the outer links of A and K, which still hold 0 and 200
- •(b) — also changes e, but K still points forward to T
- •(d) — changes the outer links b and e instead of the links facing the insertion point
Key rule: Inserting a node between P and Q in a doubly linked list changes exactly two existing pointers, P's next and Q's previous; the new node's own two pointers are set, and nothing else moves.
Algorithm and Programming · AI-written, may contain errors
This question comes from the past questions IPA Japan publishes, translated into English by ITPEC Practice. ITPEC Practice is an independent study tool and is not affiliated with IPA or ITPEC. See the original paper (PDF) or Report an issue.