Trees (Module 8.1) Flashcards

1
Q

What is a collection of nodes?

A

trees

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

Trees are inherently ___________!

A

recursive

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

There are _____ nodes in a tree.

A

N

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

There are _________ edges in a tree.

A

N-1

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

What are nodes with the same parent called?

A

siblings

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

What are nodes with no children called?

A

leaves

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

What is a sequence of nodes in which each successive node is connected by an edge to the previous node?

A

path

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

What determines the depth of a node?

A

the length from the root

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

What is the height of a node?

A

the longest path from the node to a leaf

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

How many parents can a tree node have?

A

1

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

Can tree nodes have cycles?

A

No!

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

Tree nodes can’t have children that are __________ or __________ on the tree

A

on the same level, above

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

Which traversal method visits nodes by exploring as far down a branch as possible before backtracking?

A

Depth-First Traversal

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

What are the 3 variations for Depth-First Traversal?

A

1) Preorder Traversal
2) Inorder Traversal
3) Postorder Traversal

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

What is the order for Preorder Traversal?

A

Root –> Left –> Right

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

What is the order for Inorder Travel?

A

Left –> Root –> Right

17
Q

What is the order for Postorder Traversal?

A

Left –> Right –> Root

18
Q

Which traversal method visits nodes level by level, starting at the root and moving horizontally across each level?

A

Breadth-First Traversal

19
Q

How is Breadth-First traversal usually implemented to track nodes at the current level?

A

using a queue

20
Q

What is the variation for Breadth-First traversal that’s useful for finding the shortest path or levels in a tree?

A

Level Order

21
Q

Are Depth-First Traversal algorithms recursive?