Question
It is useful to have a unique representation of binary trees that can be written compactly. For simplicity, we assume that each node of the
It is useful to have a unique representation of binary trees that can be written compactly. For simplicity, we assume that each node of the tree will contain one Character. We represent a tree by a pair of strings, which I call chars and children. The chars is a pre-order listing of the contents of the nodes. The children string tells about the children of the corresponding node from chars as follows:
2 | The node has two children. |
0 | The node has no children. |
L | The node only has a left child. |
R | The node only has a right child. |
For example:
chars = "+a*-bcd"; children = "2022000"; represents the tree in Weiss Figure 18.11 (a)
chars = "7215349"; children = "220LR00"; represents the tree in Weiss Figure 19.4 (a).
What are the values of chars and children for the tree below?
For a different tree we have:
chars = "THEQUICKBROWN"; children = "2R220002R0RL0";
Show the order of the nodes in an in-order traversal of the tree.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started