FazBrowse Wikipedia Viewer | Main Page |
Search Wikipedia:
|
Viewing: https://en.wikipedia.org/wiki/Random_binary_tree

Random binary tree

Contents
    Strahler number
    Treaps and randomized binary search trees
Uniformly random binary trees
Random split trees

c. These five trees are each assigned probability 1/5 by the uniform distribution (top). The distribution generated by random insertion orderings (bottom) assigns the center tree probability 1/3, because two of the six possible insertion orderings generate the same tree; the other four trees have probability 1/6.

In computer science and probability theory, a random binary tree is a binary tree selected at random from some probability distribution on binary trees. Different distributions have been used, leading to different properties for these trees.

Random binary trees have been used for analyzing the average-case complexity of data structures based on binary search trees. For this application it is common to use random trees formed by inserting nodes one at a time according to a random permutation. The resulting trees are very likely to have logarithmic depth and logarithmic Strahler number. The treap and related balanced binary search trees use update operations that maintain this random structure even when the update sequence is non-random.

Other distributions on random binary trees include the uniform discrete distribution in which all distinct trees are equally likely, distributions on a given number of nodes obtained by repeated splitting, binary tries and radix trees for random data, and trees of variable size generated by branching processes.

For random trees that are not necessarily binary, see random tree.

26=13 of being generated, whereas the other four trees each have \\tfrac16</math>.{{sfnp|Sedgewick|Flajolet|2013|p=286}}"}},"i":0}}]}'>probability n keys, the expected value of the length of the path from the root to log" denotes the natural logarithm function and the y, of the probability that y is an ancestor of [x,y]. Because each key in the interval is equally likely to be first, this happens with probability inverse to the length of the interval. Thus, the keys that are adjacent to x, the keys one step away have probability 2log⁡n+O(1) bound above. This bound also holds for the expected search path length for a value
0<β<1 satisfying the equation

\\displaystyle 2\\beta e^{1-\\beta}=1.</math><ref>{{harvtxt|Robson|1979}}; {{harvtxt|Pittel|1985}}; {{harvtxt|Devroye|1986}}; {{harvtxt|Mahmoud|1992}}, pp. 91–99; {{harvtxt|Reed|2003}}.</ref>"}},"i":0}}]}'>13 of being a leaf in the tree. This is because it is a leaf when it inserted after its two neighbors, which happens for two out of the six permutations of it and its two neighbors, all of which are equally likely. By similar reasoning, the smallest and largest key have probability (n+1)/3.

Strahler number

edit

The Strahler number of vertices in any tree is a measure of the complexity of the subtrees under those vertices. A leaf (external node) has Strahler number one. For any other node, the Strahler number is defined recursively from the Strahler numbers of its children. In a binary tree, if two children have different Strahler numbers, the Strahler number of their parent is the larger of the two child numbers. But if two children have equal Strahler numbers, their parent has a number that is greater by one. The Strahler number of the whole tree is the number at the root node. For log3n+o(log⁡n) has been proven.

Treaps and randomized binary search trees

edit

In applications of binary search tree data structures, it is rare for the keys to be inserted without deletion in a random order, limiting the direct applications of random binary trees. However, algorithm designers have devised data structures that allow arbitrary insertions and deletions to preserve the property that the shape of the tree is random, as if the keys had been inserted randomly.

If a given set of keys is assigned numeric priorities (unrelated to their values), these priorities may be used to construct a Cartesian tree for the numbers, the binary search tree that would result from inserting the keys in priority order. By choosing the priorities to be independent random real numbers in the unit interval, and by maintaining the Cartesian tree structure using tree rotations after any insertion or deletion of a node, it is possible to maintain a data structure that behaves like a random binary search tree. Such a data structure is known as a treap or a randomized binary search tree.

Variants of the treap including the zip tree and zip-zip tree replace the tree rotations by "zipping" operations that split and merge trees, and that limit the number of random bits that need to be generated and stored alongside the keys. The result of these optimizations is still a tree with a random structure, but one that does not exactly match the random permutation model.

Uniformly random binary trees

edit
Uniformly random binary tree with 100 nodes

The number of binary trees with n-node tree of this type is

\\sqrt{\\pi n} - 3 + O\\left(\\frac{1}{\\sqrt n}\\right)</math>.{{sfnp|Sedgewick|Flajolet|2013|p=288}}"}},"i":0}}]}'>n-node binary tree is 1−p. If it is internal, its two children are trees generated recursively by the same process.
  • In the version where the root node must be internal, its left and right children are determined to be internal with probability 1−p, independently of each other. In the case where they are internal, they are the roots of trees that are generated recursively by the same process.
  • Trees generated in this way have been called binary Galton–Watson trees. In the special case where p≤12 the resulting tree is almost certainly finite, whereas for \\tfrac12"}}'>p>12 it is infinite with positive probability. More precisely, for p</math>,"}},"i":0}}]}'>any

    1−p of tails, until the first flip at which the number of tails exceeds the number of heads (for the model in which an external root is allowed) or exceeds one plus the number of heads (when the root must be internal), and then use this sequence of coin flips to determine the choices made by the recursive generation process, in depth-first order.

    Because the number of internal nodes equals the number of heads in this coin flip sequence, all trees with a given number p affects the variation in the size of trees generated by this process, but for a given size the trees are generated uniformly at random. For values of p=12, smaller values of p=12 there is no finite bound on the expected size of trees generated by this process. More precisely, for p</math>,"}},"i":0}}]}'>any is p=12 this gives 1 + 1 + 1 + 1 + ⋯, a divergent series.

    p=\\tfrac12</math>,"}},"i":0}}]}'>For probability

    12, has been studied as a model for speciation, where it is known as the critical branching process. In this process, each species has an exponentially distributed lifetime, and over the course of its lifetime produces child species at a rate equal to the lifetime. When a child is produced, the parent continues as the left branch of the evolutionary tree, and the child becomes the right branch.

    Another application of critical Galton–Watson trees (in the version where the root must be internal) arises in the Karger–Stein algorithm for finding minimum cuts in graphs, using a recursive edge contraction process. This algorithm calls itself twice recursively, with each call having probability at least 2log2n, reaching the base case of its recursion. The success probability \\Omega(1/\\log n)</math>,"}},"i":0}}]}'>is 2log2n. The analysis of these trees can be applied to the computational complexity of trie-based sorting algorithms.

    A variant of the trie, the radix tree or compressed trie, eliminates empty external nodes and their parent internal nodes. The remaining internal nodes correspond to prefixes for which both possible extensions, by a zero or a one bit, are used by at least one of the randomly chosen numbers. For a radix tree for log2n+2log2n+o(log⁡n), both with high probability.

    Random split trees

    edit

    Luc Devroye and Paul Kruszewski describe a recursive process for constructing random binary trees with (0,1), assigns the first n) for

  • 1 2 Drmota (2009), p. 19.
  • ↑ Knuth (1997).
  • ↑ Knuth (1973).
  • ↑ Vuillemin (1980).
  • 1 2 Sedgewick & Flajolet (2013), p. 286.
  • ↑ Morin (2014).
  • ↑ Hibbard (1962); Knuth (1973); Mahmoud (1992), p. 75.
  • ↑ Robson (1979); Pittel (1985); Devroye (1986); Mahmoud (1992), pp. 91–99; Reed (2003).
  • ↑ Brown & Shubert (1984).
  • ↑ Kruszewski (1999).
  • 1 2 Martínez & Roura (1998); Seidel & Aragon (1996); Morin (2014).
  • ↑ Tarjan, Levy & Timmel (2021); Gila, Goodrich & Tarjan (2023).
  • ↑ Drmota (2009), p. 26.
  • ↑ Sedgewick & Flajolet (2013), p. 287.
  • ↑ Knuth (2005), p. 15.
  • ↑ Sedgewick & Flajolet (2013), p. 288.
  • ↑ Devroye & Kruszewski (1995).
  • ↑ Mahmoud (1992), p. 63.
  • ↑ Flajolet, Raoult & Vuillemin (1979).
  • ↑ Shreve (1966).
  • ↑ Aldous (1996).
  • ↑ Rémy (1985); Mäkinen & Siltaneva (2003); Knuth (2005), pp. 16–17.
  • ↑ Burd, Waymire & Winn (2000).
  • ↑ This is a special case of a general theorem about criticality and extinction probabilities in Galton–Watson processes, according to which the extinction probability is the smallest positive root of the formula g(x)=(1−p)+px2. See e.g. Jagers (2011), Theorem 2.1, p. 92. Jagers carries out the calculation of this root for the binary case on p. 97.
  • ↑ For the connection between trees and random walks (as generated by random coin flips) see e.g. Section 6, "Walks and trees" pp. 483–486, of Harris (1952).
  • ↑ Broutin, Devroye & Fraiman (2020). More generally, every Galton–Watson process, conditioned on producing trees of a certain size, produces the same probability distribution as a critical Galton–Watson process: see section 2 of Kennedy (1975).
  • ↑ For the expected number of nodes at each level of the tree, see e.g. Athreya & Ney (1972), Section I.A.2: Moments, p. 4.
  • ↑ By the equivalence between trees and random walks, this is the same as the probability of first returning to zero after

  • View original on Wikipedia | Back | FazBrowse Home