Trees Flashcards

(5 cards)

1
Q

What is a tree ?

A

A tree is a data structure that is made up of a collection of nodes,
One root node, each node has zero or more children,
Edges or links connect parent and child nodes.

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

What are the different tree properties ?

A

Depth of node - Number of edges between the root and that node,
Height of tree - Longest path from root to a leaf (node with no children),
Size - Total number of nodes.

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

What is a binary tree ?

A

Each node has at most two children,
Defined recursively - Either empty, or a root with two binary subtrees.

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

What are the types of binary trees ?

A

Full - Every node has 0 or 2 children,
Complete - All levels filled left to right except possibly the last,
Perfect - Complete tree with all leaves at the same depth,
Balanced - Height difference between left and right <= 1,
Degenerate - Each parent has only one child (linked list).

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

What are the two types of tree traversal ?

A

Depth first search,
Breadth first search.

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