Advertisement
Chris_M_Thomasson

Tree...

Jan 3rd, 2022
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.50 KB | None | 0 0
  1.  
  2. Root 0, 2-ary:
  3.  
  4.  
  5. [0] 0
  6. / \
  7. / \
  8. / \
  9. / \
  10. / \
  11. [1] 1 2
  12. / \ / \
  13. / \ / \
  14. [2] 3 4 5 6
  15. / \ / \ / \ / \
  16. [3] 7 8 9 10 11 12 13 14
  17. ................................
  18.  
  19. It goes on forever. There is no end. There are an infinite number of levels, however, no leafs in sight... ;^)
  20.  
  21. Want to get to the number 12, we go: (0, 2, 5, 12), or, starting at the root, go (R, L, R) RLR... a finite path to 12. Want to get to a big number, go all rights... (0, 2, 6, 14, ...). Notice a pattern? You can never reach infinity, even though the tree is infinite in and of itself...
  22.  
  23. starting at root, 9 = LRL, and 10 = LRR
  24.  
  25. ;^)
  26.  
  27.  
  28.  
  29. Want to get to the children of a node? Say 5...
  30.  
  31. left = 2*5+1 = 11
  32. right = 2*5+2 = 12
  33.  
  34. Say, 2...
  35.  
  36. left = 2*2+1 = 5
  37. right = 2*2+2 = 6
  38.  
  39. Perhaps 1...
  40.  
  41. left = 2*1+1 = 3
  42. right = 2*1+2 = 4
  43.  
  44. Oh shi*, how about zero:
  45.  
  46. left = 2*0+1 = 1
  47. right = 2*0+2 = 2
  48.  
  49.  
  50.  
  51.  
  52. Three:
  53.  
  54. left = 2*3+1 = 7
  55. right = 2*3+2 = 8
  56.  
  57. On and on... On and on....
  58.  
  59. https://youtu.be/soIewreZjls
  60.  
  61. LOL!!!!!
  62.  
  63.  
  64. Hey now, a level is finite, yet there are an infinite amount of them, and a level can hold an infinite amount of elements... So, humm:
  65.  
  66. [0] = { 0 }
  67. [1] = { 1, 2 }
  68. [2] = { 3, 4, 5, 6 }
  69. [3] = { 7, 8, 9, 10, 11, 12, 13, 14 }
  70. ...
  71.  
  72. ;^)
  73.  
  74.  
  75. Want to extend things, in a sense?
  76.  
  77. The children of 7 are:
  78.  
  79. left = 2*7+1 = 15 (LLLL from root?)
  80. right = 2*7+2 = 16
  81.  
  82. Oh my, WM! They do go on forever:
  83.  
  84. 14:
  85.  
  86. left = 2*14+1 = 29
  87. right = 2*14+2 = 30
  88.  
  89. Oh... How about 13?
  90.  
  91. left = 2*13+1 = 27
  92. right = 2*13+2 = 28
  93.  
  94. 27, 28, 29, 30, ... Notice the pattern?
  95.  
  96. Funny... Humm.... Lets try to get the parent of say, 11 and 12:
  97.  
  98. parent = ceil(11 / 2 - 1) = 5
  99. parent = ceil(12 / 2 - 1) = 5
  100.  
  101. Humm... How about, 6 and 5
  102.  
  103.  
  104. Humm... Let's try to abstract it:
  105.  
  106. The children of 5 are 11 and 12, lets check:
  107.  
  108. child_left = 2*5+1 = 11
  109. child_right = 2*5+2 = 12
  110.  
  111. The parent of 11 and 12 are 5, lets check:
  112.  
  113. parent = ceil(11 / 2 - 1) = 5
  114. parent = ceil(12 / 2 - 1) = 5
  115.  
  116. Therefore,
  117.  
  118. ceil((2*5+1) / 2 - 1) = 5
  119. ceil((2*5+2) / 2 - 1) = 5
  120.  
  121.  
  122. Humm...
  123.  
  124. left = ary * node_value + 1
  125. right = ary * node_value + 2
  126.  
  127. and:
  128.  
  129. parent = ceil(left / ary - 1)
  130. parent = ceil(right / ary - 1)
  131.  
  132. ?
  133.  
  134. What about 3-ary? God damn ASCII art! Anyway:
  135.  
  136.  
  137.  
  138.  
  139. [0] 0
  140. /|\
  141. / | \
  142. / | \
  143. / | \
  144. / | \
  145. / | \
  146. / | \
  147. [1] 1 2 3
  148. /|\ /|\ /|\
  149. / | \ / | \ / | \
  150. [2] 4 5 6 7 8 9 10 11 12
  151. ..............................................
  152.  
  153. Lets see here... This is 3-ary, therefore, the three children of, say 2 are: 7, 8, 9... Humm:
  154.  
  155. 3-ary, children, for 2 are:
  156.  
  157. child_left = 3*2+1 = 7
  158. child_middle = 3*2+2 = 8
  159. child_right = 3*2+3 = 9
  160.  
  161. Humm... They Work!
  162.  
  163. Lets try getting the parent of say, 11, which should be 3:
  164.  
  165.  
  166. ceil(11 / 3 - 1) = 3
  167.  
  168. okay, how about 10:
  169.  
  170. ceil(10 / 3 - 1) = 3
  171.  
  172. And, perhaps 12:
  173.  
  174. ceil(12 / 3 - 1) = 3
  175.  
  176. Humm... Afaict, this seems to work with a highly experimental fractal encryption of mine called RIFC that stores data in the roots of fractals. Humm... Interesting to me. Should world in integer land, instead of floating heck!
  177.  
  178. Fwiw:
  179.  
  180. https://github.com/ChrisMThomasson/fractal_cipher/blob/master/RIFC/cpp/ct_rifc_sample.cpp
  181.  
  182. :^)
  183.  
  184.  
  185.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement