# アルゴリズム – Is a complete binary tree classified as a forest?

## Question: Question:

What kind of cases are classified as forests?

According to Wikipedia , the definitions of trees and forests are as follows:

Tree: Undirected graph that is connected and does not have a cycle Mori: Undirected graph that does not have a cycle

All trees are forests because the special shape of the forest is trees. A complete binary tree is, of course, a forest.

Here are some examples. Think of x as a clause and-and | as a branch.

``````    x---x
|
x---x---x
|
x---x
``````

This is a tree and a forest .

``````    x---x
|   |
x---x---x
|
x---x
``````

This is neither a tree nor a forest because it has a cycle.

``````    x---x         x
|             |
x---x---x    x----x----x
|
x---x
``````

It's not a tree because it's not connected, but it's a forest .
(If you look at the two connected graphs individually, it is a tree / forest )

``````    x---x         x
|   |         |
x---x---x    x----x----x
|
x---x
``````

This is neither a tree nor a forest because it has a cycle and is not connected.
(If you look only at the graph on the right, it is a tree / forest )

``````    x---x        x
|            |
x---x---x---x----x----x
|
x---x
``````

This is a tree and a forest .

Scroll to Top