Tree traversal Flashcards

1
Q

Pre - order traversal

A

the value of the node is always output first before checking for nodes on the left and then for nodes on the right.

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

use of pre-order traversal:

A

copying a tree
Pre-fix of an expression

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

How does pre-order traversal implement a recursive algorithm?

A

it is repeatedly called until all of the nodes have been processed. The first time that the function is called, it will be passed the address (pointer) of the root node. Each time the function is called a new node will be referenced (the left or right child node), until the base case is reached.

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

In - order traversal:

A

the value of the node is output after the left-hand nodes are inspected but before the right hand node is inpsected.

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

Use of In-Order traversal:

A

In a binary search tree the nodes are arranged in correct order so, in-order traversal would output the nodes in correct order.
-In-fix of an expression

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

Post-order traversal:

A

the value of the node is output after both the left AND the right nodes have been explored.

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

use of Post-order traversal:

A

used to convert from infix to postfix notation
emptying a tree

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

What is the same as post-order traversal?

A

Depth first search because it uses a stack to manage the backtracking and the nodes are processed the final time they are visited

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