data_structures.linked_list.xor_linked_list¶
XOR Linked List implementation A memory-efficient doubly linked list that uses the XOR of node addresses. Each node stores one pointer that is the XOR of the previous and next node addresses. https://en.wikipedia.org/wiki/XOR_linked_list Example: >>> xor_list = XORLinkedList() >>> xor_list.insert(10) >>> xor_list.insert(20) >>> xor_list.insert(30) >>> xor_list.to_list() [10, 20, 30]
Classes¶
Module Contents¶
- class data_structures.linked_list.xor_linked_list.XORLinkedList¶
- _xor(node_a: Node | None, node_b: Node | None) int¶
Helper function to get the XOR of two node IDs (simulated addresses). Names ‘node_a’ and ‘node_b’ are used for descriptive parameters.
- insert(value: int) None¶
Inserts a value at the end of the list.