Trees Flashcards

(8 cards)

1
Q

What is a tree?

A

A tree is a connected, undirected graph with no cycles.

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

What is a characteristic that not all trees have?

A

Not all trees have roots!

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

What is a rooted tree?

A

A tree where one node has been designated as the root.

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

What is a binary tree?

A

A rooted tree where each parent node has at most two child nodes.

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

What is a binary search tree?

A

An ordered binary tree.

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

Which item in a line of items is the root?

A

The first item that is entered is always the root!

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

Searching for an item in a binary search tree.

A

Just like a binary search, searching for an item in a binary tree is an O(logn) process.
This is because, on each attempt, the size of the list halves.

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

How do you represent a binary tree?

A

Binary trees can be represented using three arrays.
One stores the data for each node, one stores the left pointers, and one stores the right pointers.

Pointers are stored at the same location in the arrays as corresponding data item.

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