Ordered Binary trees Flashcards

1
Q

Describe Ascending/Descending in-order, post-order, pre-order

A

Ascending in order: left then parent then right 123
Descending in-order: right then parent then left 321

Ascending pre-order: parent then left then right 213
Descending pre-order: parent then right then left 231

Ascending post-order: left then right then parent 132
Descending post-order: right then left then parent 312

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

Describe balance. What is a balanced tree? What is a fully balanced tree?

A

Balanced: every non-empty node has a difference of at most one in the number of items on its left and its right.

Fully balanced: Every non-empty node has an equal number of items on its left and right. Size N Depth log_2(N+1)

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

What is a binary tree? What is an ordered binary tree?

A

Each node can have at most two children

A binary tree has an ordering of the tree data in it. There is a total order to the data. Ordered from left to right.

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

What is the depth of a tree?

A

The number of rows
Empty: depth = 0
one node: depth = 1

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

What is a tree sort?

A

Start with unsorted list. Insert into tree. Scan tree in ascending order to obtain numbers in ascending order.

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

Describe the in place algorithm

A

Algorithm for balancing trees

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

Describe tree data, tree data value, tree node

A

Trees consist of tree nodes. Nodes might contain data, might have children.
A non empty node contains a tree data value, left child, right child

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