File tree Expand file tree Collapse file tree
data_structures/linked_list Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11"""
22XOR Linked List implementation
3- A memory-efficient doubly linked list using XOR of node addresses.
4- Each node stores one pointer that is the XOR of previous and next node addresses.
3+ A memory-efficient doubly linked list that uses the XOR of node addresses.
4+ Each node stores one pointer that is the XOR of the previous and next node addresses.
5+ https://en.wikipedia.org/wiki/XOR_linked_list
56Example:
67>>> xor_list = XORLinkedList()
78>>> xor_list.insert(10)
@@ -18,7 +19,7 @@ class Node:
1819 def __init__ (self , value : int ) -> None :
1920 """Initializes a Node with a value and a null pointer."""
2021 self .value = value
21- self .both : int = 0 # XOR of prev and next node ids
22+ self .both : int = 0 # XOR of prev and next node IDs
2223
2324
2425class XORLinkedList :
You can’t perform that action at this time.
0 commit comments