To see the 10 minute youtube video that talks through this topic, click here.
What's The Best Sorting Algorithm
Sometimes we need to sort our data. Maybe we have a list of names, or a list of numbers, and we want them to be in order.
There are many different sorting techniques/algorithms, but some are better than others. (And in an interview, you may be asked which is best.) There is no best sorting algorithm, it depends on the data/situation. But let's look at when to use each sorting algorithm. Factors In Deciding A Good Sorting Algorithm
Top-Tier Sorting Algorithms
There are a lot of sorting algorithms out there, but since we're only looking at this for the sake of an interview question, we'll go over four good ones.
Here's the code for those sorting algorithms.
You can download the code from github, here.
When To Use Each Sorting Algorithm (Decision Tree)
So here's how to decide which sorting algorithm to use (generally):
Note that this is a very good guideline (and probably good enough for an interview), but you should be aware that advanced techniques exist. For example, any sort can be made "stable", but sometimes it's not worth it. There's always trade-offs.
Like this content and want more? Feel free to look around and find another blog post that interests you. You can also contact me through one of the various social media channels.
Twitter: @srcmake Discord: srcmake#3644 Youtube: srcmake Twitch: www.twitch.tv/srcmake Github: srcmake
References
1. Programming Interviews Exposed by Eric Giguere, John Mongan, Noah Suojanen. 2. geekforgeeks Selection Sort. 3. geekforgeeks Insertion Sort. 4. geekforgeeks Merge Sort. 5. geekforgeeks Quick Sort. Comments are closed.
|
AuthorHi, I'm srcmake. I play video games and develop software. Pro-tip: Click the "DIRECTORY" button in the menu to find a list of blog posts.
![]() License: All code and instructions are provided under the MIT License.
|