Data Structures & AlgorithmsVery hardGATE CS · DSA

XOR linked list: each node stores link = address(prev) XOR address(next). Which statement is correct?

  1. A. It allows O(1) random access
  2. B. Deleting a node needs no knowledge of its neighbours
  3. C. It needs two pointer fields per node
  4. D. Given the addresses of two adjacent nodes you can move in either direction, but a single node pointer alone is not enough to traverse

Correct answer: D. Given the addresses of two adjacent nodes you can move in either direction, but a single node pointer alone is not enough to traverse

next = link XOR prev, so traversal needs the previous node's address as well. It saves one pointer per node compared with a doubly linked list but still gives only sequential access.

More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions

Exams that ask this topic