encyclopegia.org

Tree sort

A tree sort is a sort algorithm that builds a binary search tree from the elements to be sorted, and then traverses the tree (in-order) so that the elements come out in sorted order. Its typical use is sorting elements online: after each insertion, the set of elements seen so far is available in sorted order. Tree sort can be used as a one-time sort, but it is equivalent to quicksort as both recursively partition the elements based on a pivot, and since quicksort is in-place and has lower overhead, tree sort has few advantages over quicksort. It has better worst case complexity when a self-balancing tree is used, but even more overhead.

A tree sort is a sort algorithm that builds a binary search tree from the elements to be sorted, and then traverses the tree (in-order) so that the elements come out in sorted order. Its typical use is sorting elements online: after each insertion, the set of elements seen so far is available in sorted order. Tree sort can be used as a one-time sort, but it is equivalent to quicksort as both recursively partition the elements based on a pivot, and since quicksort is in-place and has lower overhead, tree sort has few advantages over quicksort. It has better worst case complexity when a self-balancing tree is used, but even more overhead. data Tree a = Leaf | Node (Tree a) a (Tree a) insert :: Ord a => a -> Tree a -> Tree a insert x Leaf = Node Leaf x Leaf insert x (Node t y s) | x y = Node t y (insert x s) flatten :: Tree a -> [a] flatten Leaf = [] flatten (Node t x s) = flatten t ++ [x] ++ flatten s treesort :: Ord a => [a] -> [a] treesort = flatten . foldr insert Leaf In the above implementation, both the insertion algorithm and the retrieval algorithm have worst-case scenarios. == External links== == References==

References

  1. Binary Tree Sort · retrieved 2026-11-17 · rev 1333478496
    Cite this reference

    MLA "Binary Tree Sort." McLuckie, Keith; Barber, Angus (1986). 2026-11-17. https://en.wikipedia.org/wiki/ISBN_(identifier). Accessed 24 November 2026.

    Chicago "Binary Tree Sort." McLuckie, Keith; Barber, Angus (1986). 2026-11-17. https://en.wikipedia.org/wiki/ISBN_(identifier).

    APA McLuckie, Keith; Barber, Angus (1986). (2026). Binary Tree Sort. Retrieved November 24, 2026, from https://en.wikipedia.org/wiki/ISBN_(identifier)

Cite this article

MLA

"Tree sort." encyclopegia.org, 2026, https://encyclopegia.org/wiki/tree-sort. Accessed 24 November 2026.

Chicago

"Tree sort." encyclopegia.org. Accessed November 24, 2026. https://encyclopegia.org/wiki/tree-sort.

APA

encyclopegia.org. (2026). Tree sort. Retrieved November 24, 2026, from https://encyclopegia.org/wiki/tree-sort

Accessed November 24, 2026 · CC BY-SA 4.0 · citation page · JSON

Related articles

Pope Adrian 37th Psychristiatric

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

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

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