Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between ordered and unordered (rooted) trees

Tags:

algorithm

tree

I am reading algorithms by Robert Sedwick. Some definitions from the book are shown below.

A tree (also an ordered tree) is a node (called the root) connected to a sequence of disjoint trees. Such a sequence is called a forest.

A rooted tree (or unordered tree) is a node (called the root) connected to a multiset of rooted trees. (such a multiset is called an unordered forest.

My questions on the above text are

  1. I am having difficutlty in understanding above defintions. Can any one please explain with examples.
  2. What does author mean by disjoint trees?
  3. What does author mean by multiset rooted trees?

Thanks for your time and help

like image 771
venkysmarty Avatar asked Sep 21 '12 06:09

venkysmarty


People also ask

What is the difference between ordered and unordered trees?

A tree (also an ordered tree) is a node (called the root) connected to a sequence of disjoint trees. Such a sequence is called a forest. A rooted tree (or unordered tree) is a node (called the root) connected to a multiset of rooted trees. (such a multiset is called an unordered forest.

What is the difference between a tree and a rooted tree?

A tree (also an ordered tree) is a node (called the root) connected to a sequence of disjoint trees. Such a sequence is called a forest. A rooted tree (or unordered tree) is a node (called the root) connected to a multiset of rooted trees. (such a multiset is called an unordered forest. I am having difficutlty in understanding above defintions.

What is unordered forest?

Such a sequence is called a forest. A rooted tree (or unordered tree) is a node (called the root) connected to a multiset of rooted trees. (such a multiset is called an unordered forest. I am having difficutlty in understanding above defintions.

What is an ordered rooted tree?

Note: An ordered rooted tree is rooted tree where the children of each internal vertex are ordered. Here order means child are represented in order of left to right. What is the difference between a tree and a graph?


1 Answers

  1. A tree by this definition is more or less what we normally understand by tree: a node connected to an ordered sequence of (sub)trees. It's a recursive definition: if the sequence is empty, the node is called leaf, and if not, each of the tree in the sequence is also "a node connected to an ordered sequence of (sub)trees."
  2. By disjoint the author means that the subtrees don't have nodes in common.
  3. The definition means that the subtrees of a rooted tree are not in a particular order and that they may be repeated. A multiset is kind of like a set that allows multiples.

An ordered tree (a "tree" of the first definition) has the subtrees in a particular order, and the subtree sequence cannot contain the same tree twice, because the subtrees must be disjoint. A rooted tree does not have these restrictions; by this definition a root might have a subtree twice, in a structure that resembles a cycle.

I don't have Sedwick's book to check if or why this definition makes sense; a more common definition or rooted tree would use a normal set for subtrees, rather than a multiset. Perhaps the intention is to allow multiple links between a node and its children while disallowing other kinds of cycles, such as links between siblings and cousins.

like image 114
Joni Avatar answered Nov 22 '22 18:11

Joni