All mock tests are FREE till 31 December — register to save your progress

Given below are two statements: one is labelled as Assertion A and the other is labelled as Reason R.
Assertion A: It is possible to create a doubly linked list using only one pointer field in every node.
Reason R: By storing the XOR of the addresses of the previous and next nodes.

Pick an option to check yourself, or open the answer below.

Show answer & explanation

Correct answer: A. Both A and R are true and R is the correct explanation of A

Explanation

An XOR linked list stores prev ⊕ next in one field. Knowing one neighbour's address, the other can be recovered, so R explains A.

More Data Structures and Algorithms questions