Simple Sorting Flashcards

1
Q

Define

Bubble Sort

A

Compare two array values. If one on the left is greater, swap them. Move one position to right.
Swaps and comparisons O(N^2), slow

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

Define

Selection Sort

A

Goes through whole list and identifies shortest, swaps that value with position 0’s value. Next move smallest to position 1, etc.
Swaps O(N)
Comparisions O(N^2)

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

Define

Insertion Sort

A

O(N^2) time.
Twice as fast as bubble sort
Often used as the final stage of more sophisticated sorts.
Takes the next unsorted variable and inserts into the appropriate position amongst the already sorted.

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