encyclopegia.org

Finger tree

In computer science, a finger tree is a purely functional data structure that can be used to efficiently implement other functional data structures.[src] A finger tree gives amortized constant time access to the "fingers" (leaves) of the tree, which is where data is stored, and concatenation and splitting logarithmic time in the size of the smaller piece.[src] It also stores in each internal node the result of applying some associative operation to its descendants.[src] This "summary" data stored in the internal nodes can be used to provide the functionality of data structures other than trees.[src]

In computer science, a finger tree is a purely functional data structure that can be used to efficiently implement other functional data structures.[src] A finger tree gives amortized constant time access to the "fingers" (leaves) of the tree, which is where data is stored, and concatenation and splitting logarithmic time in the size of the smaller piece.[src] It also stores in each internal node the result of applying some associative operation to its descendants.[src] This "summary" data stored in the internal nodes can be used to provide the functionality of data structures other than trees.[src] data FingerTree a The digits of the finger tree can be transformed into a list like so: data Digit a = One a | Two a a | Three a a a | Four a a a a And so on the image, the top level has elements of type a, the next has elements of type Node a because the node in between the spine and leaves, and this would go on meaning in general that the nth level of the tree has elements of type Node^n a, or 2–3 trees of depth n.[src] This means a sequence of n elements is represented by a tree of depth Θ(log n).[src] Even better, an element d places from the nearest end is stored at a depth of Θ(log d) in the tree.[src] This process can also be done with other trees, like the 2–3–4 tree at right.[src] This helps to see that the Digits are actually the annotations which were inside the tree, and each digit is conceptually associated with a subtree that may be empty.[src] &reducer\ (\prec)\ (Node2 \ a \ b)\ z &=&\ a\ \prec(b\ \prec\ z) \\ &reducer\ (\prec)\ (Node3 \ a \ b \ c)\ z &=&\ a\ \prec(\ b\prec(c\ \prec\ z )) \\ \\ &reducel\ (\succ)\ z\ (Node2 \ b \ a)\ &=&\ (z\ \succ\ b)\ \succ\ a \\ &reducel\ (\succ)\ z\ (Node3 \ c \ b \ a)\ &=&\ ((z\ \succ\ c) \succ\ b) \succ\ a \\ \end{align} \begin{align} \mathrm{instance}& \ Reduce \ FingerTree \ \mathrm{where} && \\ &reducer\ (\prec)\ (Empty)\ z\ &=&\ z \\ &reducer\ (\prec)\ (Single \ x)\ z &=&\ x\ \prec\ z \\ &reducer\ (\prec)\ (Deep \ pr \ m \ sf)\ z &=&\ pr\ \prec'\ (m\ \prec\ (sf\ \prec'\ z)) \\ & \ \ \ \ where \\ & \ \ \ \ \ \ \ \ (\prec')\ = reducer\ (\prec) \\ & \ \ \ \ \ \ \ \ (\prec)\ = reducer\ (reducer\ (\prec)) \\ \\ & reducel\ (\succ)\ z\ (Empty)\ &=&\ z \\ & reducel\ (\succ)\ z\ (Single\ \ x)\ &=&\ z\ \succ\ x \\ & reducel\ (\succ)\ z\ (Deep\ \ pr \ m \ sf)\ &=&\ ((z\ \succ'\ pr)\ \succ\ m)\ \succ'\ sf) \\ & \ \ \ \ where \\ & \ \ \ \ \ \ \ \ (\succ')\ = reducel\ (\succ) \\ & \ \ \ \ \ \ \ \ (\succ)\ = reducel\ (reducel\ (\succ))\\ \end{align} Finger trees can efficiently implement random-access sequences.[src] This should support fast positional operations including accessing the nth element and splitting a sequence at a certain position.[src] To do this, we annotate the finger tree with sizes.[src] newtype Size = Size{ getSize :: N } deriving (Eq, Ord) instance Monoid Size where ∅ = Size 0 Size m ⊕ Size n = Size (m + n) The N is for natural numbers.[src] The new type is needed because the type is the carrier of different monoids.[src] Another new type is still needed for the elements in the sequence, shown below.[src] newtype Elem a = Elem{ getElem :: a } newtype Seq a = Seq (FingerTree Size (Elem a)) instance Measured (Elem a) Size where ||Elem|| = Size 1 These lines of code show that instance works a base case for measuring the sizes and the elements are of size one.[src] The use of newtypes doesn't cause a run-time penalty in Haskell because in a library, the Size and Elem types would be hidden from the user with wrapper functions.[src] With these changes, the length of a sequence can now be computed in constant time.[src]

22 sentences · 22 cited inline · 0 references stored

References

No reference rows published for this article.

Cite this article

MLA

"Finger tree." encyclopegia.org, 2026, https://encyclopegia.org/wiki/finger-tree. Accessed 01 December 2026.

Chicago

"Finger tree." encyclopegia.org. Accessed December 1, 2026. https://encyclopegia.org/wiki/finger-tree.

APA

encyclopegia.org. (2026). Finger tree. Retrieved December 1, 2026, from https://encyclopegia.org/wiki/finger-tree

Accessed December 1, 2026 · CC BY-SA 4.0 · citation page · JSON

Related articles

Ti -Tree

stub · references available

Siberian Tree Frog

stub · references available

Olive-tree Warbler

stub · references available

Angela Finger-Erben

stub · references available

Tree Pipit

stub · references available

Matschie's tree-kangaroo

stub · references available

phylogenetic tree

stub · references available

Gray-bellied pencil-tailed tree-mouse

stub · references available
CC BY-SA 4.0 · share-alike · https://en.wikipedia.org/w/index.php?oldid=1376552856 · 0.5 · snapshot enwiki-001376552856

Cite · JSON · Search

Related services and records

Services

  • Estate — measured countries, lanes and facts
  • Intel — live corroborated events
  • Legal — statutes, cases and citations
  • Encyclopedia — articles with inline sources
  • Space — launches, satellites and orbits
  • Search — federated search and reports
  • Pass — passport account and SSO
  • Corpora — read-only corpus origins
  • e01 — self-hosted corpora and tools
  • Careers — open roles: frontier engineers and sales partners
  • Index — every corpus, paper and record
  • Estate guide — what a public data estate is
  • Founder — Lois-Kleinner Alpasan
  • Records — DOIs and external deposits
  • Documents — one-pagers, PDFs and QR codes
  • Brand kit — logos and share images
  • Papers — plain-language briefs with citations
  • Browser — search engine, PWA and bookmarklet
  • Anticloud — the operator and its projects

As seen in Business Insider · 336 outlets · evidence DOIs · plain-language papers

Text and metadata only; each target carries its own sources. Missing data is published as no-data, never estimated.