Skip to content

Latest commit

 

History

History
14 lines (11 loc) · 534 Bytes

README.md

File metadata and controls

14 lines (11 loc) · 534 Bytes

<< [06] Implement a XOR linked list >>

An XOR linked list is a more memory efficient doubly linked list. Instead of each node holding next and prev fields, it holds a field named both, which is a XOR of the next node and the previous node. Implement a XOR linked list; it has an add(element) which adds the element to the end, and a get(index) which returns the node at index.

Example:

>>> xll = coding_problem_06()
>>> for cnt in range(0, 4):
...     xll.add(cnt)
>>> xll.get(2) == 2
True