Tree datastructures: Difference between revisions

Add nest task "hint" and notes
(Add nest task "hint" and notes)
Line 10:
 
A common datastructure for trees is to define node structures having a name and a, (possibly empty), list of child nodes. The nesting of nodes captures the indentation of the tree. Lets call this '''the nest form'''.
<pre># E.g. if child nodes are surrounded by brackets
# and separated by commas then:
RosettaCode(rocks(code, ...), ...)
# But only an _example_</pre>
 
Another datastructure for trees is to construct from the root an ordered list of the nodes level of indentation and the name of that node. The indentation for the root node is zero; node 'rocks is indented by one level from the left, and so on. Lets call this '''the indent form'''.
Line 27 ⟶ 31:
# transform the indent format to final nest format and show it.
# Compare initial and final nest formats which should be the same.
 
;Note:
* It's all about showing aspects of the contrasting datastructures as they hold the tree.
* The word "golfing" may be substituted by "trolling" in the tree as golfing can be friendly fun! (just not for RC examples).
* Comparing nested datastructures is secondary - saving formatted output as a string then a string compare would suffice for this task, if its easier.
<br>
 
Show all output on this page.
Anonymous user