I want to optimize a bidirectional node traversal algorithm.
Because the node is bidirectional, it may cause an infinite loop. The current algorithm uses memory records. However, memory writing will be slower and not friendly to multi-threading.
So I hope I can remove the memory write operation. And the insertion and deletion of nodes is equal to O(1).
Does anyone have any good ideas?