Binary Search Trees in Lean Check a result Declarations Bibliography Lean source

Chapter 35Simulating fingers

The multi-finger model of Chapter 10 keeps several persistent fingers in one tree. The pointer machine of Chapter 7 has a single cursor that starts at the root for every request. To simulate a finger, the cursor must reach it in a constant number of steps, however deep the finger is in the tree that is being simulated. Demaine, Iacono, Langerman and Özkan (2013) do this by reshaping the tree around the fingers. The paths between them are stored compactly, so that every finger stays near the root. The library builds its own version of their construction, with explicit constants.

  • Section 35.1 defines the building blocks. A BST deque is a binary search tree whose minimum and maximum are at depth one, so that nodes can be pushed or popped at either end in amortized constant work. A tendon stores a long path of a tree as two such deques.
  • Section 35.2 assembles them into a finger hand, which keeps every finger a constant number of steps from the root for a fixed number of fingers, and simulates each finger instruction at an amortized cost that is constant for a fixed number of fingers.

With kk fingers the simulation costs at most 344+60(k+1)344 + 60(k+1) times the multi-finger cost, in a proof file outside the reading interface. The reading interface states the case of one finger, the lazy finger: the comparison of dynamic BSTs with static lazy-finger trees in Chapter 16. The combination of Chapter 29 uses the hand with two fingers.