0

Is there a way to serialize any tree?

Mind maps are trees. Text is serial. I wonder if there is an elegant way to serialize trees.

An n-ary tree can be serialized, if we represent the absence of a node as NULL. But that is not intuitive. We do not think in terms of "two absences of new ideas".

Trees can be serialized recursively. But that solution is complicated, making use of lines and indentation. Git's commit history feels similar.

Trees, as graphs, can be described by their nodes and edges. Somehow that comes across as describing the behavior and history of a tree than itself to me, which may not even make sense.

Is there a well-known, simple, elegant way to serialize infinite -ary trees? Equivalently, is there an innate, implicit representation for trees, and trees alone? On a related note, how can I define a tree purely generatively, instead of "graphs that satisfy such and such qualities"? Or perhaps, is there a textbook on such topics that a non-CS major can read up on?

stalostan
  • 5
  • 1
  • 4
  • 1
    I'd wager that more than half of all standardized serialization formats represent trees of unbounded arity. s-expressions, JSON, XML, ASN.1, avro, protobuf, RIFF, etc. etc. – Matt Timmermans Oct 20 '22 at 13:20
  • Note that ordered infinite-arity trees are isomorphic to binary trees. Just call the left link "first child" and the right link "right sibling". – Matt Timmermans Oct 20 '22 at 13:25

0 Answers0