Sorting Algorithms

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/8

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.

9 Terms

1
New cards

Bubble Sort

  • Compare adjacent elements and swap if needed

  • Best Case O(n) sorted data

  • Worst Case O(n²) unsorted data

  • Avg O(n²)

  • In place

  • Stable

2
New cards

Bucket Sort

  • Put elements into multiple buckets

  • Sort Buckets individually and then merge back together

  • best O(n + k)

  • worst O(n²)

3
New cards

Counting Sort

  • Count how many times each number occurs using array

  • list numbers in another array based on occurences

  • Stable

  • O(n + k) time

4
New cards

Insertion Sort

  • Marks first sorted element

  • works through list putting elements in correct place relative to sorted list

  • Best Case O(n) sorted data

  • Worst Case O(n²) unsorted data

  • Stable

  • In place

5
New cards

Merge Sort

  • Break array into smaller and smaller list

  • sort small lists

  • merge back together

  • consistent O(nlogn)

  • not in place

  • stable

6
New cards

Quick Sort

  • choose a pivot

  • have two pointers at opposite ends of array

  • move right pointer until find element less than pivot

  • move left pointer until find element greater than pivot

  • swap values at pivots

  • repeat until pointers cross

  • O(nlogn) best

  • O(n²) worst

7
New cards

Radix Sort

  • sort numbers digit by digit from LSD to MSD

  • O(nk) time

  • Good for large numbers with fixed size

  • strings

8
New cards

Selection Sort

  • find min element

  • swap with next unsorted element

  • O(n²)

9
New cards