Sorting Algorithms Flashcards

1
Q

Which sorting algorithm only sorts if the array is not already sorted?

A

Insertion Sort

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

Why is it called “insertion sort”

A

Each pass through the array takes the first element that is out of place and inserts it into its proper place

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

Which sorting algorithm uses two loops?

A

Bubble sort

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

Which sorting algorithm will have the largest element in it’s proper position after one pass?

A

Bubble sort

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

What is the “key” in a selection sort?

A

The smallest entry

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

How does selection sort work?

A

Find the smallest value and replace with lowest element available.

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

Which sorting algorithm compares 2 adjacent elements on each pass?

A

Bubble sort

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

How is information about a function call stored?

A

Dynamically using the runtime stack

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

What information is saved with a function call?

A

Parameters, variables, and return address

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

What is the data about a function call named?

A

Activation Record

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

What’s another word for activation record?

A

Stack Frame

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

What is the anchor in recursion?

A

The last recursive call

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

What does the anchor do in a recursive call?

A

Ensures we don’t fall into an infinite loop

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

What are the three types of recursion?

A

1) Linear
2) Binary
3) Multiple

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

Which two algorithms are based on a divide and conquer approach?

A

Merge Sort and Quick Sort

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

What is the anchor for merge sort?

A

If there is zero or one element, return array.

17
Q

Which algorithm recursively sorts by dividing the set in 2

A

Merge Sort

18
Q

Which algorithm uses a pivot?

A

QuickSort

19
Q

Which algorithm recursively divides the elements into 3 sets

A

QuickSort