Consider the given memory representation of the singly linked list where start points to the address of first node of the linked list, which is memory…
Consider the given memory representation of the singly linked list where start points to the address of first node of the linked list, which is memory location 0.
Memory representation of the singly linked list
Memory location | Item value | Pointer to next element
0 | A | 4
1 | E | 2
2 | B | NULL
3 | |
4 | C | 1
If a new node whose data value is X is inserted after the node whose data value is E in any free location available in the memory, then what will the memory representation be after inserting the new node?
Show answerHide answer
Correct answer: (B) Memory representation of the linked list after inserting node X Memory location | Item value | Pointer to next element 0 | A | 4 1 | E | 3 2 | B | NULL 3 | X | 2 4 | C | 1
Explanation
The list is A(0) → C(4) → E(1) → B(2). X goes into free location 3. E's pointer changes to 3, and X points to B at 2, giving A → C → E → X → B as in option B.