Information On Binary Trees: Database

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 1

Information on Binary Trees

A binary tree is often defined recursively as either (a) being empty, or (b) consisting of a root node together with left and right subtrees, both of which are binary trees. It is this definition that is most useful from the point of view of data structures in computer science. From the mathematical point of view these objects are not trees. Changing (a) from "empty" to "a single vertex" gives a definition equivalent to that of ordered trees in which every node is either a leaf (no children) or has two children. These are sometimes called extended binary trees. In either case, they are usually parameterized by n, the number of applications of rule (b) that are used. In the extended binary tree illustrated above there are 5 internal nodes (the brown circles, which correspond to applications of rule (b)) and 6 leaves (the blue squares, which correspond to applications of rule (a)). By removing the blue edges and the leaves you obtain the corresponding binary tree. The number of extended binary trees with n internal nodes is given by the nth Catalan number (2n)!/[(n+1)!n!] which, for n = 1,2,...,15, has the values 1, 2, 5, 14, 42, 132, 429, 1430, 4862, 16796, 58786, 208012, 742900, 2674440, 9694854. This is sequence A000100(M1459) in Neil J. Sloane's database of integer sequences. The number of extended binary trees with n internal nodes and leftmost leaf at level m is m(2nm-1)!/[(n-m)!n!]. The table of these numbers, shown below, is known as "Catalan's triangle" if the rows are read backwards. This is sequence A033184 in Neil J. Sloane's database of integer sequences. m= n=1 2 3 4 5 6 7 8 1 1 1 2 5 1 2 5 1 3 9 1 4 1 2 3 4 5 6 7 8

14 14

42 42 28 14 5 1 132 132 90 48 20 6 1 429 429 297 165 75 27 7 1

Binary trees with n nodes are often represented as bitstrings b1 b2 ... b2n obtained by traversing the equivalent extended binary tree in preorder

You might also like