# Finger search tree

This article is about search trees that allow searching from interior nodes. For the purely functional data structure, see finger tree.

In computer science, finger search trees are a type of binary search tree that keeps pointers to interior nodes, called fingers. The fingers speed up searches, insertions, and deletions for elements close to the fingers, giving amortized O(log n) lookups, and amortized O(1) insertions and deletions. It should not be confused with a finger tree nor a splay tree, although both can be used to implement finger search trees.

Guibas et al.[1] introduced ﬁnger search trees, by building upon B-trees. The original version supports ﬁnger searches in O(log d) time, where d is the number of elements between the ﬁnger and the search target. Updates take O(1) time, when only O(1) moveable ﬁngers are maintained. Moving a ﬁnger p positions requires O(log p) time. Huddleston and Mehlhorn refined this idea as level-linked B-trees.[2]

Tsakalidis proposed a version based on AVL trees that facilitates searching from the ends of the tree; it can be used to implement a data structure with multiple fingers by using multiple of such trees.[3]

To perform a finger search on a binary tree, the ideal way is to start from the finger, and search upwards to the root, until we reach the least common ancestor,[4][5] also called the turning node,[3] of x and y, and then go downwards to find the element we're looking for. Determining if a node is the ancestor of another is non-trivial.

An example of performing finger search on a treap.

Treaps, a randomized tree structure proposed by Seidel and Aragon,[5] has the property that the expected path length of two elements of distance d is O(log d). For finger searching, they proposed adding pointers to determine the least common ancestor(LCA) quickly, or in every node maintain the minimum and maximum values of its subtree.

A book chapter has been written that covers finger search trees in depth.[4] In which, Brodal suggested an algorithm to perform finger search on treaps in O(log d) time, without needing any extra bookkeeping information; this algorithm accomplishes this by concurrently searching downward from the last candidate LCA.