User Tools

Site Tools


tutorials:exercises_binary_ternary_tree

From binary to ternary tree

Change the default 3d binary tree to a ternary version, a tree with tree instead of two branches.

Solution

To achieve this, we need to add another branch and explicitly rotate the branches to (0, 120, and 240) degree.

public void run3() [
  A(x) ==> F(x) 
    [RH(  0) RU(45) RH(90) A(x*0.8)]  // first branch  
    [RH(120) RU(45) RH(90) A(x*0.8)]  // second branch
    [RH(240) RU(45) RH(90) A(x*0.8)]; // third branch
]
tutorials/exercises_binary_ternary_tree.txt · Last modified: 2025/10/28 17:54 by MH