coding-interview|May 08, 2019|2 min read

List of Sorting Algorithms

TL;DR

Overview of all major sorting algorithms — bubble, selection, insertion, merge, quick, heap, counting, radix — with Big-O comparisons and when to use each.

List of Sorting Algorithms

This topic is one of the most common studied. When somebody started preparation of coding interviews. Sorting algorithms would in his top 2 topics. Even typical computer science graduate study sorting algorithms 3-4 times before they complete graduation.

Why you should study Sorting Algorithms

  • These are one of the most fundamental building block which helps in other complex algorithms.
  • If you understand different tricks and basics around these algorithms, you can solve many-many more complex problems. Or, you can utilize the code somewhere.
  • Most common techniques Divide and Conquer, covers few sorting algorithms. Which gives you more understanding of Divide and Conquer algorithms.
  • In other computational algorithms, you must be using one of sorting algorithms either directly or indirectly.
  • These are used in database queries

And, the list is endless.

Which algorithm to study?

There are lot of sorting algorithms available, if you search in wikipedia. But, you should consider reading few of them. In below section, I will mention the important ones.


Different Sorting Algorithms

There are lot of Sorting algorithms out there. I’ve categorized them as below:


Most Basic Ones

Very basic ones. You should consider reading them at least once.

Most Used and Optimized algorithms

Below algorithms must be on your tips.

  • Merge Sort
  • Quick Sort
  • Heap Sort

Other Algorithms

You should be familiar with these algorithms, although not much deep knowledge is required.

  • Bucket Sort
  • Counting Sort
  • Radix Sort

Time complexities of Sorting Algorithms

Algorithms Average(Expected) Running time Worst Running time
Insert Sort O(n^2) O(n^2)
Bubble Sort O(n^2) O(n^2)
Selection Sort O(n^2) O(n^2)
Quick Sort O(n log n) O(n^2)
Merge Sort O(n log n) O(n log n)
Heap Sort O(n log n) O(n log n)

Related Posts

What FAANG companies expect in their interview from candidates

What FAANG companies expect in their interview from candidates

Its every software engineer’s dream to work with the big FAANG companies…

Magical usage of Bitwise operators - Get optimized solutions for many arithmatic problems

Magical usage of Bitwise operators - Get optimized solutions for many arithmatic problems

Introduction I will list some of the interesting usage of bitwise operators…

How to prepare for your next Coding Interview

How to prepare for your next Coding Interview

Here are some tips while preparing for your coding interviews. 1. Do study or…

How to nail your Coding Interview

How to nail your Coding Interview

Here are some tips while giving your coding interviews. 1. Never try to jump to…

Coding Interview - Useful Terms Cheatsheet

Coding Interview - Useful Terms Cheatsheet

Big-O notation In simpler terms, its kind of a unit to measure how efficient an…

Coding Interview Cheatsheet

Coding Interview Cheatsheet

Latest Posts

Claude Code Skills — Build a Better Engineering Workflow with AI-Powered Code Reviews, Security Scans, and More

Claude Code Skills — Build a Better Engineering Workflow with AI-Powered Code Reviews, Security Scans, and More

Most developers use Claude Code like a search engine — ask a question, get an…

Building an AI Voicebot for Visitor Check-In — A Practical Guide to Handling the Messy Parts

Building an AI Voicebot for Visitor Check-In — A Practical Guide to Handling the Messy Parts

Every office lobby has the same problem: a visitor walks in, nobody’s at the…

Server Security Best Practices — Complete Hardening Guide for Production Systems

Server Security Best Practices — Complete Hardening Guide for Production Systems

Every breach post-mortem tells the same story: an unpatched service, a…

Staff Engineer Study Plan for MAANG Interviews — The Complete 12-Week Roadmap

Staff Engineer Study Plan for MAANG Interviews — The Complete 12-Week Roadmap

If you’re a Senior Engineer (L5) preparing for Staff (L6+) roles at MAANG…

XSS and CSRF Explained — The Complete Guide with Real Attack Examples and Defenses

XSS and CSRF Explained — The Complete Guide with Real Attack Examples and Defenses

XSS and CSRF have been in the OWASP Top 10 for over a decade. They’re among the…

OWASP Top 10 (2021) — Every Vulnerability Explained with Code

OWASP Top 10 (2021) — Every Vulnerability Explained with Code

The OWASP Top 10 is the industry standard for web application security risks. If…