Trees Flashcards

1
Q

In what way is a tree hierarchical?

A

More general things are at the top and more specific things are at the bottom.

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

In any type of tree, are children of one node independent of children of another node?

A

Yes.

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

In any type of tree, are leaf nodes unique?

A

Yes, no leaf node should be accessible from more than one parent node.

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

What is an edge?

A

A connection between two nodes, showing a relationship between them.

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

How many incoming edges are connected to any one node in a tree (not including the root node)?

A

Exactly one incoming edge from another node.

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

How many outgoing edges are connected to any one node in a tree?

A

Each node may have several outgoing edges.

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

What is the level of a node within a tree?

A

The level of a node ‘n’ is the number of edges on the path from the root node to ‘n’.

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

What is the level of the root node of a tree?

A

0.

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

What is the height of a tree?

A

The height of a tree is equal to the maximum level of any node in the tree.

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

What property defines a binary tree?

A

If each node in the tree has a maximum of two children, we say that the tree is a binary tree.

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

Name the three commonly used tree traversal patterns.

A

Preorder; inorder; and postorder.

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

How is preorder tree traversal carried out?

A

The root node is visited first, then recursively preorder traverse the left subtree, followed by recursively preorder traversing the right subtree.

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

How is inorder tree traversal carried out?

A

Recursively do an inorder traversal of the left subtree, visit the root node, and finally recursively do an inorder traversal of the right subtree?

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

How is postorder tree traversal carried out?

A

Recursively do a postorder traversal of the left subtree and right subtree followed by a visit to the root node.

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

What is the heap order property?

A

In a heap, for every node X with parent P, the key in P is smaller than or equal to the key in X.

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

What is a min heap?

A

A binary heap where the smallest key is always at the front.

17
Q

What is a max heap?

A

A binary heap where the largest key value is always at the front.

18
Q

What makes a binary tree a complete binary tree?

A

A complete binary tree is tree in which each level has all of its nodes, with the exception being the bottom level of the tree, which we fill in from left to right.