Memorising an ordered sequence with shifting positions

This is super interesting, thanks @erikfromholland!

This is a really elegant solution.

You’re essentially preserving when an item was introduced and what preceded it at the time of insertion, rather than continuously updating its position.

An append-only insertion history represented as a tree, with depth-first traversal visiting newer branches first.

It reminds me of event sourcing: preserve the historical records and reconstruct the current state from them.

I’m curious how retrieval performance scales as the sequence gets longer, especially when trying to access an arbitrary position rather than reconstructing the entire sequence.

1 Like