I know that from a general tree you can construct a unique binary tree, but is the reverse true? i.e can you get a unique general tree from a binary tree?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Yes. The following transformation is reversible:
Given a general tree with ordered but not indexed children,
encode the first child as the left child of its parent, and each other node as a right child of its (former) sibling.
The reverse is:
Given a binary tree with distinguished left and right children, read the left child of a node as its first child and the right child as its next sibling.
So, the following tree
is encoded as
while the following tree
is encoded as
(read:
dis the first child ofb,cis the sibling ofa).Note that you can encode any rooted forest (with ordered components, otherwise the representation is not unique) by assigning a sibling to the root, so this
would be read as
here is another method to get a unique general (undirected) tree from a binary tree:
this operation is reversible:
So,