Unit 10 - Recursion Flashcards

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

Recursive method

A

One that calls itself

Contains at least one base case which halts the recursion and at least one recursive call -> conditional

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

Each recursive call contains

A

its own local variables, including formal parameters

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

Any recursive solution can be replicated through

A

use of iterative approach

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

Infinite recursion

A

Value is not changing in a way that allow base case to be reached -> CallStackOverFlowException

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

Parameter values capture

A

progress of recursive process

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

Recursion can be used to traverse

A

String, array, and ArrayList objects

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

Binary search algorithm

A

Data must be sorted
Starts in middle of sorted array or ArrayList and eliminates half of the array or ArrayList in each iteration until desired value is found or all elements has been eliminated

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

Binary search algorithm can be written

A

both iteratively or recursively

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

What do we o when lowPosition > highPosition?

A

Return -1

Value does not lie within list

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

Merge sort

A

Recursive sorting algorithm that can be used to sort elements in an array or ArrayList

mergeSort(myList)
{
      mergeSort(left)
      mergeSort(right)
      mergeSort(left & right)
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Merge Method

A

Copy original elements to a temporary array and compares the two array to sort a list

merge(myArray, low, middle, high)

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