Articles
Sorting Algorithms
Published Aug 12, 2020Updated Jan 21, 2021
Binary search was efficient when given a pre-sorted data set, but what are the most efficient ways to actually sort data sets? There are many different sorting algorithms, but you are going to focus on three of the most common: bubble sort, merge sort, and quicksort. Each has pros and cons when it comes to their efficiency, as you can see in the table below:
Best Case | Worst Case | Average Case | Space Complexity | |
---|---|---|---|---|
Bubble Sort | O(n) | O(n^2) | O(n^2) | O(1) |
Merge Sort | O(n log n) | O(n log n) | O(n log n) | O(n) |
Quicksort | O(n log n) | O(n log n) | O(n^2) | O(log n) |
Codecademy Team
'The Codecademy Team, composed of experienced educators and tech experts, is dedicated to making tech skills accessible to all. We empower learners worldwide with expert-reviewed content that develops and enhances the technical skills needed to advance and succeed in their careers.'
Meet the full teamRelated articles
- Article
Implementing the Merge Sort Algorithm in Python
Learn how to implement Merge Sort in Python - an algorithm with clear examples, step-by-step code, and practical applications. - Article
How to sort a list in Python
Learn how to sort lists in Python using `.sort()` and `sorted()`. Explore custom sorting with keys, descending order sorting, and apply real-world sorting techniques efficiently. - Article
How to Sort Lists of Lists in Python with Examples
Learn how to sort lists of lists in Python. Explore simple to advanced methods, including, `sorted()`, `map()`, and multi-criteria sorting for complex data.
Learn more on Codecademy
- Course
Learn Sorting Algorithms with Python
Learn about the usefulness and efficiency of computational sorting by implementing different sorting algorithms yourself.With CertificateIntermediate3 hours - Free course
Java: Algorithms
Learn the basics of recursion and how to implement and analyze important algorithms in Java.Beginner Friendly3 hours - Skill path
Pass the Technical Interview with Python
Learn about the computer science concepts of data structures and algorithms and build implementations of each from scratch in modern Python.Includes 8 CoursesWith CertificateIntermediate25 hours