Binary Trees Flashcards

1
Q

types of trees

A

Ordered tree (implies rooted)

Binary tree (implies ordered)

m-ary tree (usually ordered)

Labeled and/or search tree

R-B Tree

AVL Tree

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

What does each node of a binary tree consist of?

A

• A value (some sort of data item) • A reference or pointer to a left child (may be null), and A reference or pointer to a right child (may be null)

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

If a binary tree is not empty it has a…?

A

root node

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

A node without a left or right child is called a…?

A

leaf

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

What is the order of a tree?

A

number of nodes

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

What is the size of a tree?

A

number of edges, order -1

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

What is the depth of a node?

A

distance from root to the node where root to root is depth of 0

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

What is the height of a tree?

A

depth of the deepest node

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

For the following what is the order, size, depth (from a⇒a, a⇒e, a⇒k) and height

A

order = 12

size = 11

depth = 0, 2, 3 respectively

height = 4

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

When is an m-ary tree balanced?

A

When the heights of the subtrees of every node never differ by more than one.

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

When is a m-ary tree full?

A

full if every node has either 0 or m children

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

When is a m-ary tree complete?

A

complete if all levels have no missing siblings/cousins, except possibly the last (partial left-filled) level

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

pre, post and in order

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

what is it called to o visit nodes from top-to-bottom and left-to-right

A

level-order traversal

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

Average height for BST, R-B tree and AVL trees?

A

BST: 4 lg n

R-B: 2 lg n

AVL: 1.5 lg n

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