Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Root 0, 2-ary:
- [0] 0
- / \
- / \
- / \
- / \
- / \
- [1] 1 2
- / \ / \
- / \ / \
- [2] 3 4 5 6
- / \ / \ / \ / \
- [3] 7 8 9 10 11 12 13 14
- ................................
- It goes on forever. There is no end. There are an infinite number of levels, however, no leafs in sight... ;^)
- 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...
- starting at root, 9 = LRL, and 10 = LRR
- ;^)
- Want to get to the children of a node? Say 5...
- left = 2*5+1 = 11
- right = 2*5+2 = 12
- Say, 2...
- left = 2*2+1 = 5
- right = 2*2+2 = 6
- Perhaps 1...
- left = 2*1+1 = 3
- right = 2*1+2 = 4
- Oh shi*, how about zero:
- left = 2*0+1 = 1
- right = 2*0+2 = 2
- Three:
- left = 2*3+1 = 7
- right = 2*3+2 = 8
- On and on... On and on....
- https://youtu.be/soIewreZjls
- LOL!!!!!
- 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:
- [0] = { 0 }
- [1] = { 1, 2 }
- [2] = { 3, 4, 5, 6 }
- [3] = { 7, 8, 9, 10, 11, 12, 13, 14 }
- ...
- ;^)
- Want to extend things, in a sense?
- The children of 7 are:
- left = 2*7+1 = 15 (LLLL from root?)
- right = 2*7+2 = 16
- Oh my, WM! They do go on forever:
- 14:
- left = 2*14+1 = 29
- right = 2*14+2 = 30
- Oh... How about 13?
- left = 2*13+1 = 27
- right = 2*13+2 = 28
- 27, 28, 29, 30, ... Notice the pattern?
- Funny... Humm.... Lets try to get the parent of say, 11 and 12:
- parent = ceil(11 / 2 - 1) = 5
- parent = ceil(12 / 2 - 1) = 5
- Humm... How about, 6 and 5
- Humm... Let's try to abstract it:
- The children of 5 are 11 and 12, lets check:
- child_left = 2*5+1 = 11
- child_right = 2*5+2 = 12
- The parent of 11 and 12 are 5, lets check:
- parent = ceil(11 / 2 - 1) = 5
- parent = ceil(12 / 2 - 1) = 5
- Therefore,
- ceil((2*5+1) / 2 - 1) = 5
- ceil((2*5+2) / 2 - 1) = 5
- Humm...
- left = ary * node_value + 1
- right = ary * node_value + 2
- and:
- parent = ceil(left / ary - 1)
- parent = ceil(right / ary - 1)
- ?
- What about 3-ary? God damn ASCII art! Anyway:
- [0] 0
- /|\
- / | \
- / | \
- / | \
- / | \
- / | \
- / | \
- [1] 1 2 3
- /|\ /|\ /|\
- / | \ / | \ / | \
- [2] 4 5 6 7 8 9 10 11 12
- ..............................................
- Lets see here... This is 3-ary, therefore, the three children of, say 2 are: 7, 8, 9... Humm:
- 3-ary, children, for 2 are:
- child_left = 3*2+1 = 7
- child_middle = 3*2+2 = 8
- child_right = 3*2+3 = 9
- Humm... They Work!
- Lets try getting the parent of say, 11, which should be 3:
- ceil(11 / 3 - 1) = 3
- okay, how about 10:
- ceil(10 / 3 - 1) = 3
- And, perhaps 12:
- ceil(12 / 3 - 1) = 3
- 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!
- Fwiw:
- https://github.com/ChrisMThomasson/fractal_cipher/blob/master/RIFC/cpp/ct_rifc_sample.cpp
- :^)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement