Sorting Info Flashcards
(13 cards)
Bubble Sort: Best, Average, Worst, Stable?, In Place?, Use
Best: O(n)
Average: O(n^2)
Worst: O(n^2)
Stable? Yes
In Place? Yes
Use: Small nearly sorted sets
Selection Sort: Best, Average, Worst, Stable?, In Place?, Use
Best: O(n^2)
Average: O(n^2)
Worst: O(n^2)
Stable? No, changes relative order of equal elements
In Place? Yes, doesn’t require extra memory
Use: Small nearly sorted sets
Insertion Sort: Best, Average, Worst, Stable?, In Place?, Use
Best: O(n)
Average: O(n^2)
Worst: O(n^2)
Stable? Yes
In Place? Yes
Use: Small nearly sorted sets, timsort
Merge Sort: Best, Average, Worst, Stable?, In Place?, Use
Best: O(nlogn)
Average: O(nlogn)
Worst: O(nlogn)
Stable? Yes
In Place? No
Use: large dataset, extra space not a concern
Quick Sort: Best, Average, Worst, Stable?, In Place?, Use
Best: O(nlogn)
Average: O(nlogn)
Worst: O(n^2)
Stable? No
In Place? Yes
Use: general purpose, efficient, speed, large dataset. avoid worst case.
Stack (FILO) First in Last Out Running Time and Uses
Running Time: O(1)
Undo Redo
Browser Back
Memory
Queue (FIFO) First in, first out
Running Time: O(1)
Simulations Traffic/Airport
Print spools
Process/job queue
Min max Priotity Queue Running Time and Uses
Running time: O(1)
Process/CPU Schedules
Task List
Ticketing System
Ordered Map and Set
Running Time: O(log(n))
Unordered map and set
Running Time: O(1)
Array/vector Running Time (back, middle, front)
Running Time: O(1) for access and insertion at back
O(n) for insertion and removal elsewhere
List
Running Time: O(1) for insertion and removal, but not for random access
Stack, queue, priority queue Running Time
O(1) for adding to, removing from, wnd accessing proper ends