Sorting Flashcards

1
Q

Bubble Sort

A

Iterates over every element, comparing each pair and swapping if necessary. No more iterations are needed once no swaps take place. It has high time complexity O(n^2) best case but can be improved to O(n) if given sorted list.

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

Selection Sort

A

Iterates over each element and swaps it with the smallest element int the remaining list. Works well for small sets. Time complexity is O(n^2) best case.

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

Insertion Sort

A

Every repetition removes an element from the input, and inputs into the correct position. Best when the input data is nearly sorted or the input size is small. Time complexity is O(n^2) worst case and O(n) best case.

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

Shell Sort

A

It is an improvement of insertion sort and is faster than bubble, selection, and insertion sorting. Time complexity is O(nlogn) worst case and O(n) best case.

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

Merge Sort

A

The list is divided into two parts and these are solved recursively, then they are merged.Used for sorting a linked list. It is insensitive to the initial ordering of the list. Time complexity is O(nlogn) best and worst case.

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

Heap Sort

A

Used to sort priority queues. Time complexity is O(nlogn) best and worst case.

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

Quicksort

A

It is an example of a divide-and-conquer algorithm. It is also called partition exchange sort. The array is divided into two, and the two sub-arrays are sorted by recursive calls. In the recursion, if there are 1 or no items in the array, return. Else, an element is picked at random to use as the “pivot”. This array is in turn split into 2. Time complexity is O(n^2) worst case and O(nlogn) best case.

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

Tree Sort

A

Each element is scanned and placed into the proper position of the binary search tree. Time complexity is O(n^2) worst case and O(nlogn) best case.

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

Counting Sort

A

Assumes that each element is an integer in the range of 1 to K. Time complexity of O(n) in best and worst cases.

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

Bucket/Bin Sort

A

Time complexity of O(n) in best and worst cases.

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

Radix Sort

A

Time complexity of O(n) in best and worst cases.

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

Topological Sort

A

Used to sort graphs.

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

External Sorting

A

Uses another sort algorithm but allows to sort under memory constraints.

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