Dottleshead ★ Posted May 28, 2022 Share #1 Posted May 28, 2022 ... know your Big O notation. Time Sort Average Best Worst Space Stability Remarks Bubble sort O(n^2) O(n^2) O(n^2) Constant Stable Always use a modified bubble sort Modified Bubble sort O(n^2) O(n) O(n^2) Constant Stable Stops after reaching a sorted array Selection Sort O(n^2) O(n^2) O(n^2) Constant Stable Even a perfectly sorted input requires scanning the entire array Insertion Sort O(n^2) O(n) O(n^2) Constant Stable In the best case (already sorted), every insert requires constant time Heap Sort O(n*log(n)) O(n*log(n)) O(n*log(n)) Constant Instable By using input array as storage for the heap, it is possible to achieve constant space Merge Sort O(n*log(n)) O(n*log(n)) O(n*log(n)) Depends Stable On arrays, merge sort requires O(n) space; on linked lists, merge sort requires constant space Quicksort O(n*log(n)) O(n*log(n)) O(n^2) Constant Stable Randomly picking a pivot value (or shuffling the array prior to sorting) can help avoid worst case scenarios such as a perfectly sorted array. 1 Link to comment Share on other sites More sharing options...
Thaddeus Kosciuszko Posted May 28, 2022 Share #2 Posted May 28, 2022 1 hour ago, Dottles said: Quicksort O(n*log(n)) O(n*log(n)) O(n^2) Constant Stable Randomly picking a pivot value (or shuffling the array prior to sorting) can help avoid worst case scenarios such as a perfectly sorted array. This must be the algorithm the US Post Office uses to sort the mail. 1 Link to comment Share on other sites More sharing options...
shootingstar Posted May 28, 2022 Share #3 Posted May 28, 2022 Is this related to software code?? Really the world has...musicians, software developers...whose headspace is another world, another language. Link to comment Share on other sites More sharing options...
Dottleshead ★ Posted May 28, 2022 Author Share #4 Posted May 28, 2022 It’s an algorithm so it could be anything. But yes most commonly seen in software code. Look up Big O Notation. Link to comment Share on other sites More sharing options...
Solution JerrySTL ★ Posted May 28, 2022 Solution Share #5 Posted May 28, 2022 The only Big O that I know about: 1 Link to comment Share on other sites More sharing options...
shootingstar Posted May 28, 2022 Share #6 Posted May 28, 2022 35 minutes ago, Dottles said: It’s an algorithm so it could be anything. But yes most commonly seen in software code. Look up Big O Notation. Ok, now it you told me it was beautiful interesting design, I would look it up. Link to comment Share on other sites More sharing options...
Dottleshead ★ Posted May 28, 2022 Author Share #7 Posted May 28, 2022 It’s nerd talk for efficiency Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now