final exam eeek! Flashcards

1
Q

What is the relationship between elements in a tree called?

A

Edge or arc

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

The height of a tree?

A

the maximum depth of any node in the tree

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

The depth of a node in a tree?

A

the length of the path from the root to the node

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

True/False
Each node in the structure may have only one parent

A

True

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

Edges in a tree can’t create cycles meaning…

A

a path from the node can’t lead back to itself

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

A binary tree is different from a normal tree how?

A

Each node can only have at most 2 children

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

The three types of binary trees are

A

perfect, complete, and full

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

What is a full binary tree?

A

Every node has exactly two child nodes or zero child nodes

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

What is a perfect binary tree?

A

a full binary tree where all the leaves are at the same depth

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

In a perfect binary tree, if we know height is h, how many leaves does it have?

A

2^h

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

In a perfect binary tree, if we know height is h, how many nodes does it have?

A

(2^(h+1)) - 1

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

In a perfect binary tree, if we know the tree has n nodes, what is the height?

A

log(n)

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

What is a complete binary tree?

A

binary tree that is perfect except for the deepest level, where all the nodes are all as far left as possible

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

What is the binary search tree property?

A

Within a binary search tree, the key of each node N is greater than all the keys in N’s left subtree and less than or equal to all the keys in N’s right subtree

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

What is a depth-first traversal?

A

visits descendants before siblings –> moves as far downwards as it can first before going sideways

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

Three types of depth-first traversals?

A

Preorder, inorder, and postorder

17
Q

Preorder traversal

A

NLR

18
Q

Inorder traversal

A

LNR

19
Q

postorder traversal

A

LRN

20
Q

Which depth-first traversal visits the nodes in sorted ascending order?

A

Inorder traversal

21
Q

What is a breadth-first traversal?

A

goes as far across the tree before moving down

22
Q

What is the process to add an element to a BST?

A