Section 7 Chapter 42 - Trees Flashcards

1
Q

Tree

A

Connected, undirected graph with no cycles

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

Rooted tree

A

A tree where one vertex has been designated as the root

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

Node

A

Contains the data and are connected together via edges

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

Edge

A

Connects two nodes

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

Root

A

The only node with no parent. All other nodes are descendants of the root

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

Child

A

node A is a child of node B is they have a direct connection and node B is closer to the root than node A.

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

Parent

A

Node A is a parent of node B if they are directly connected and node A is closer to the root

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

Subtree

A

The set of nodes and edges comprised of a parent and its descendants

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

Leaf

A

A node that has no children

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

Binary tree

A

A rooted tree where each node has at most two children

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

Binary search tree

A

A binary tree that holds the items in such a way that a binary search can be conducted on the tree very easily

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

How to construct a binary search tree

A

The first item is placed at the root. When a new item is added visit the root, which becomes the current node. At each current node, if the item is less than the value of the node take the branch to the left, otherwise take the branch to the right. Repeat until you attempt to take a branch that does not exist. Add the item as a node in this place

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

The ways to traverse a binary tree (3)

A

Pre-order
In-order
Post-order

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

How to know what each traversal means

A

The prefix of each traversals refers to how whether, at each subtree, you consider the parent node first, second or third.

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

Uses for each traversal

A

Pre-order - producing prefix notation
In-order - binary search
Post-order - produce reverse polish notation

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