Group Abstract Group Abstract

Message Boards Message Boards

0
|
2.9K Views
|
4 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Extend binary tree using CreateDateStructure

Posted 3 years ago

Hello,

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!

https://reference.wolfram.com/language/ref/datastructure/BinaryTree.html

In[9]:= tree = CreateDataStructure["BinaryTree", v -> {l, b} ]

Out[9]= DataStructure[BinaryTree, {Data -> v -> {l, b}}]

In[6]:= tree["Visualization"]

enter image description here

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}}]
POSTED BY: Ziggy Stardust
4 Replies

Welcome to Wolfram Community! Please make sure you know the rules: https://wolfr.am/READ-1ST

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]

You can also embed notebook or attach notebook.

enter image description here

POSTED BY: EDITORIAL BOARD

Ah! Okay. I apologize I will edit it now.

POSTED BY: Ziggy Stardust

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.

POSTED BY: Ziggy Stardust

Dear Max,

Please check the sections "Adding Notebook" and "Code Formatting" in the rules page: https://wolfr.am/READ-1ST

POSTED BY: EDITORIAL BOARD
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard