Nodes, Trees, and Forests Flashcards

1
Q

What is a node?

A

A single element in a data structure, typically with a value and a pointer to its parent.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is a tree?

A

A hierarchical data structure of nodes with one root and no cycles; each node (except the root) has exactly one parent.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is a forest?

A

A collection of disjoint trees; in Union-Find, it represents multiple disjoint sets.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How are trees used in Union-Find?

A

Each disjoint set is represented as a tree, with the root being the set’s representative.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How are forests used in Union-Find?

A

All disjoint sets together form a forest; each tree in the forest corresponds to one set.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the root of a tree in Union-Find?

A

The node that points to itself; it represents the entire set.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What does a node store in Union-Find?

A

Its value, a pointer to its parent, and optionally a rank (for balancing).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What does ‘no cycles’ mean in a tree?

A

It means there is no path that loops back to a previously visited node; paths always move toward the root.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What happens during UNION in terms of trees?

A

Two trees (sets) are merged into one by connecting one tree’s root under the other.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What happens to the forest when UNION is called?

A

The number of trees in the forest decreases, as sets are merged together.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly