CS2004_Sorting_Algorithms_Flashcards

(10 cards)

1
Q

What is Bubble Sort?

A

Bubble Sort is a simple sorting algorithm that repeatedly steps through the list, compares adjacent elements, and swaps them if they are in the wrong order.

✅ Example: Sorting [4, 2, 1] → swap 4 and 2, then 4 and 1 → repeat until sorted.

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

What is Insertion Sort?

A

Insertion Sort builds the sorted list one item at a time by repeatedly inserting new elements into the correct position.

✅ Example: Works well on small or nearly sorted arrays.

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

What is Selection Sort?

A

Selection Sort repeatedly finds the minimum element from the unsorted part and places it at the beginning of the sorted part.

✅ Example: Always O(n²), even if the list is partially sorted.

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

What is Merge Sort?

A

Merge Sort is a divide-and-conquer algorithm that splits the list in half, recursively sorts both halves, and then merges them together.

✅ Example: Always O(n log n), good for large lists.

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

What is Quick Sort?

A

Quick Sort is a divide-and-conquer algorithm that selects a pivot, partitions the list into elements less than and greater than the pivot, and recursively sorts the sublists.

✅ Example: Average O(n log n), worst-case O(n²) with poor pivot.

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

What is Radix Sort?

A

Radix Sort is a non-comparison sort that sorts numbers by digit, starting with the least significant digit (LSD).

✅ Example: Efficient when data is bounded and digit-based.

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

What is the best-case complexity of Insertion Sort?

A

O(n) — occurs when the list is already sorted.

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

Which sorting algorithms are stable?

A

Stable sorts: Bubble Sort, Insertion Sort, Merge Sort.

✅ A stable sort preserves the relative order of equal elements.

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

Which sorting algorithm is not comparison-based?

A

Radix Sort — it sorts by processing digits rather than comparing values directly.

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

What is meant by a stable sort?

A

A sorting algorithm is stable if it preserves the order of equal elements in the original list.

✅ Example: If two items have the same value, their order remains the same.

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