Sorting Algos

0.0(0)
studied byStudied by 1 person
0.0(0)
full-widthCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/19

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

20 Terms

1
New cards

Bubble sort

Whats sorted first: LARGEST element (At the end)

Steps:
Compare adjacent elements
Swap if theyre in the wrong order
“Bubble” the largest element to the end
Repeat for remaining unsorted portion

2
New cards

Selection sort

Whats sorted first: SMALLEST element (at the beginning)

Steps:
Find the minimum element in unsorted portion
Swap it with the first unsorted position
Move sorted/unsorted boundary (iterate)
Repeat

3
New cards

Insertion sort

Whats sorted first: FIRST element

Steps:
Start with first element (considered sorted)
Take next element and insert it into correct position insorted portion
Shift elements as needed
Repeat for all elements

4
New cards

Quicksort

Whats sorted first: THE PIVOT

Steps:
Choose a pivot element
Partition: move elements left and right of the pivot (L → < pivot, R → > Pivot)
Pivot is in the final position
Recursively do the sort left and right

5
New cards

Merge sort

Whats sorted first: NONE

Steps:
Divide array in half recursively until single elements
Merge sorted halves back together
Repeat until fully sorted

6
New cards

Bubble sort time complexity

Best Case: O(n)
Average Case: O(n²)
Worst Case: O(n²)

7
New cards

Selection sort time complexity

Best Case: O(n²)
Average Case: O(n²)
Worst Case: O(n²)

8
New cards

Insertion Sort time complexity

Insert
Best Case: O(n)
Average Case: O(n²)
Worst Case: O(n²)

9
New cards

Quicksort time complexity

Best Case: O(n log n)
Average Case: O(n log n)
Worst Case: O(n²)

10
New cards

Merge sort time complexity

Best Case: O(n log n)
Average Case: O(n log n)
Worst Case: O(n log n)

11
New cards

Bubble sort properties

12
New cards

Selection sort properties

13
New cards

Insertion sort properties

14
New cards

Quicksort properties

15
New cards

Merge sort properties

16
New cards

Stable

Stable sort preserves relative order of elements with equal keys

10 2 10 → 2 10 10

17
New cards

In-place

Sorting algo that uses O(1) space → If you use an array of size 3 then it would use an extra array of size 3

18
New cards

Internal

The data is stored in ram → small enough to run in ram vs external which uses othe rdrives

19
New cards

Adaptive

Checks if its sorted or nearly sorted firs

20
New cards

Radix sort time complexity

O(dn)