I’m working on investigating binary trees and want to conduct a “Forced-based Simulation” by creating a recursive function that will populate nodes based on a set of rules. How do I add to this binary tree? The documentation does not clearly state how to do this?
Any direction would be appreciated! Thanks!
In[9]:= tree = CreateDataStructure["BinaryTree", v -> {l, b} ]
Out[9]= DataStructure[BinaryTree, {Data -> v -> {l, b}}]
In[6]:= tree["Visualization"]
Update:
So, it seems like the tree is a List of rules? I’m also not sure what “Data” Means. How can I add nodes to this binary true with rules? I also cannot find anything about this “Data” expression. It seems to be some built in something.
In[7]:= FullForm[tree]
Out[7]//FullForm= FullForm[DataStructure["BinaryTree", {"Data" -> v -> {l, b}}]]
In[8]:= OutputForm[tree]
Out[8]//OutputForm= DataStructure["BinaryTree", {"Data" -> v -> {l, b}}]
The rules explain how to format your code properly. Posting code Images doesn’t help other members to copy your code. Please EDIT your post and make sure code blocks start on a new paragraph and look framed and colored like this.
int = Integrate[1/(x^3 - 1), x];
Map[Framed, int, Infinity]
I went to the FAQ and the line that mentions not posting images calls out a tutorial but doesn’t provide a link.
Do NOT post code as images - other members need to evaluate code to
help you. It is impossible to copy code from an image. Read this
tutorial to learn how to post code properly.
I found a post on stack exchange that mentions converting the cell to raw input form but that doesn’t bring along the image of the binary tree with the code.