Trees Flashcards

1
Q

Define 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

Define root of a tree

A

start node for traversals

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

Define branch of a tree

A

path from root to an end point

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

Define height of a tree

A

number of edges connected to root node and furthest leaf node

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

Define parent and child mode

A
  • Parent node: node that comes directly before another

- Child node: no children

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

Define binary tree

A

-rooted tree where every node has at most two child nodes

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

Define binary search tree

A

ordered to optimise searching

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

Uses for trees

A
  • used in compilers to build syntax trees.
  • to represent algebraic and boolean expressions
  • speed up searching
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Records for each nodes will contain:

A
  • the index
  • the data
  • left child pointer
  • right child pointer
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Which side do you do pre-order tree traversal in?

A

left side

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

Algorithm of pre-order?

A
  • Output the node
  • Left
  • Right
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Which side do you do in-order traversal?

A

below

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

Algorithm of in-order?

A
  • left
  • output the node
  • right
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Which side do you do post-order traversal?

A

right side

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

Algorithm of post-order?

A
  • left
  • right
  • output the node
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Uses of binary search trees

A
  • in order, access the values in ascending order

- reverse in order, access the values in descending order

17
Q

Uses of expression trees

A
  • pre-order, produces the prefix version
  • in-order, produces the infix version
  • post-order, produces the postfix version