Sorting Algorithms Flashcards
Heap sort
Worst - O(nlogn)
Avg - O(nlogn)
Best - O(nlogn)
Insertion sort
Worst - O(n^2)
Avg - O(n^2)
Best - O(n)
Merge sort
Worst - O(nlogn)
Avg - O(nlogn)
Best - O(nlogn)
Quicksort
Worst - O(n^2)
Avg - O(nlogn)
Best - O(nlogn)
Quickselect
Worst - O(n^2)
Avg - O(n)
Best - O(n)
Hash Table
Worst
- Search O(n)
- Insertion O(n)
- Deletion O(n)
Avg
- Search O(1)
- Insertion O(1)
- Deletion O(1)
Binary Heap
Heapify O(n)
Find Max O(1)
Increase Key O(logn)
Insert O(logn)
Delete O(logn)
Merge O(m+n)
Linked List (sorted)
Find Max O(1)
Increase Key O(n)
Insert O(n)
Delete O(1)
Merge O(m+n)
Linked List (unsorted)
Find Max O(n)
Increase Key O(1)
Insert O(1)
Delete O(1)
Merge O(1)
Theta
Upper and lower, tight bound
equal to
Big O
Upper bound
Less than or equal to
Worst case (not always)
Omega
Lower bound
Greater than or equal to
Best case (not always)
Basic array
Worst & Avg.
- Indexing O(1)
- Search O(n)