ITPEC FE Subject A October 2025 Question 5

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

AddressEmployeeNameNextPointerPreviousPointer
100Employee A3000
200Employee T0300
300Employee K200100

Table after the addition

AddressEmployeeNameNextPointerPreviousPointer
100Employee Aab
200Employee Tcd
300Employee Kef
400Employee Gxy

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 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.