2.2 Flashcards

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

What are the three steps in a merge sort

A

Divide, Conquer, Merge

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

What does the divide section of a merge sort do

A

Splits each item in the array into their individual subarrays

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

What does the conquer section of a merge sort do

A

Each subarray is sorted individually by comparing each subarray with the next subarray

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

What does the merge section of a merge sort do

A

The sorted subarrays are merged back together in sorted order, this is repeated until all subarrays have been merged

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

How does a bubble sort work

A

Compare the current item with the next item in the array, swapping if necessary until a swap cant be made, if a swap cant be made the “current item” is the item that cant be swapped against, this process continues until the end of the array has been reached where it starts again from the beginning, this process continues until no swaps have been made where the process terminates and the list has been sorted.

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

Insertion sort stars at the second element in the input, and compares it to the element to its left. If the two elements are in the wrong order, the smaller element is placed in the
lowest position. The third element in the input is then selected. It is inserted into the correct position in the sorted portion of the input to its left. This continues until the last element is
inserted into the correct position, resulting in a fully sorted array.

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