03 / 16

What is an XOR Linked List? Why is it rarely used?

XOR Linked List

javascript
  1. 1

    It can reduce the memory used for two link fields to one XOR field.

  2. 2

    It requires pointer/address arithmetic that is unsafe or unavailable in many managed languages.

  3. 3

    It complicates debugging and memory management.

  4. 4

    Garbage collectors generally do not work naturally with XOR-encoded references.

  5. 5

    It can be difficult to reason about, maintain, and integrate with modern runtimes.

  6. 6

    The small memory saving rarely justifies the complexity in modern application software.

Difficulty: 5/10

Follow-up Questions

  • Why does XOR allow reconstruction of the neighboring address?
  • Why is this unsuitable for Java?
  • What are safer alternatives for reducing node overhead?