Section 8 Chapter 44 - Recursive Algorithms Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

Recursion

A

An algorithm or subroutine that is defined in terms of itself

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

Characteristics of a recursive algorithm (3)

A
  • A stopping condition / base case that when met will return a value not determined by calling itself again
  • For other input values the algorithm must call itself
  • The stopping condition must be reached after a finite number of calls
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How to store a binary tree if you were gonna program with it

A

A list of records. Each record holds the left branch index, right branch index and the data

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

Pseudocode for in-order traversal

A

Traverse left subtree
Visit this node (the parent of the two subtrees)
Traverse right subtree

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

Pseudocode for pre-order traversal

A

Visit this node (the parent of the two subtrees)
Traverse left subtree
Traverse right subtree

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

Pseudocode for post-order traversal

A

Traverse left subtree
Traverse right subtree
Visit this node (the parent of the two subtrees)

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

Use of a pre order traversal

A

Copying a tree

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

Use of an in order traversal

A

Outputting the contents of a binary search tree in ascending order

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

Use of a post order traversal (2)

A

Converting infix to postfix (Reverse Polish Notation), emptying a tree

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