Trees Flashcards

1
Q

What is a tree

A

A connected, undirected, non-cyclic graph

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

What is a rooted tree

A

One node is the root and all the other nodes branch away from the root

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

What is a binary tree

A

A tree where each node has a maximum of two children

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

How does a pre-order traversal work

A

Travel around the tree marking the node every time you pass the left of it

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

How does a in-order traversal work

A

Travel around the tree marking the node every time you pass below it

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

How does a post-order traversal work

A

Travel around the tree marking the node every time you pass the right of it

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

How do you implement a binary tree

A

Each node contains 3 parts: Data, left pointer to a child, right pointer to a child
When items are added to the tree the pointers will refer to the index position. If there is a -1 then the tree ends

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