On the generation of binary trees from (0-1) codes
An efficient recursive a algorithm for the generating all shapes of binary trees with n-nodes is presented. A binary tree with n-nodes is represented by 2(n−1) zeros and ones in a certain predetermined order. This scheme encodes the non-null links of a binary tree by 1's and the null links by 0...
Uloženo v:
| Vydáno v: | International journal of computer mathematics Ročník 69; číslo 3-4; s. 243 - 251 |
|---|---|
| Hlavní autoři: | , |
| Médium: | Journal Article |
| Jazyk: | angličtina |
| Vydáno: |
Abingdon
Gordon and Breach Science Publishers
01.01.1998
Taylor and Francis |
| Témata: | |
| ISSN: | 0020-7160, 1029-0265 |
| On-line přístup: | Získat plný text |
| Tagy: |
Přidat tag
Žádné tagy, Buďte první, kdo vytvoří štítek k tomuto záznamu!
|
| Shrnutí: | An efficient recursive a algorithm for the generating all shapes of binary trees with n-nodes is presented. A binary tree with n-nodes is represented by 2(n−1) zeros and ones in a certain predetermined order. This scheme encodes the non-null links of a binary tree by 1's and the null links by 0's in a pre-order traversal. The algorithm generates C
n
numbers of such codes. The algorithm is based on the idea of shifting '1' bits one space to the right. It is shown that the generation time per tree is constant O(1). The ranking and unranking algorithms are discussed. Also, an alternate way to obtain the Catalan numbers is given. |
|---|---|
| ISSN: | 0020-7160 1029-0265 |
| DOI: | 10.1080/00207169808804721 |