Sorting

A collection of important basic sorting algorithms to know.

Section Menu

How do I use this section?

1. LESSON

A Gentle Refresher Into Arrays

Let's take a scenic stroll through the world of arrays and strings and discover the connections between our everyday lives and computer science. We'll explore this fascinating subject through a structured and engaging lesson. Objective In this lesson, we will: **Understand Arrays and Strings:...

2. LESSON

Stringing Together Strings

Arrays With Characters A word with 4 characters ['M', 'O', 'N', 'A'] in a character array can be represented as follows: You see, each character gets a place in each index. Does this seem oddly familiar? There’s a more convenie...

3. LESSON

String Manipulation: Techniques and Best Practices

Why String Manipulation Matters In the ever-evolving world of software development, string manipulation stands as a fundamental and vital skill. Strings are at the heart of human-readable data. Whether it's processing user input, reading files, generating dynamic content for web pages, or simply communicating between systems,...

4. LESSON

The Set Data Structure and Set Theory

A big portion of data structures used in modern programming are directly translated from mathematics. One crucial example is the set data structure and its operations, derived from Set Theory. Understanding this data structure requires at least some prior knowledge of the mathematical perspective of th...

5. LESSON

Using the Two Pointer Technique

The Two Pointer Technique The two pointer technique is a near necessity in any software developer's toolkit, especially when it comes to technical interviews. In this guide, we'll cover the basics so that you know when and how to use this technique. <img src="https://storage.googleapis.com/algodailyrandomassets/curriculum/arrays/two-p...

6. LESSON

A Bird’s Eye View into the Sliding Windows Algorithm Pattern

A Bird’s Eye View into Sliding Windows Objective: In this lesson, we'll cover this concept, and focus on these outcomes: You'll learn what the sliding windows algorithm pattern is. We'll show you how and when to use sliding windows in programming interviews. We'll wal...

7. LESSON

The Binary Search Technique And Implementation

Objective: This article will cover the binary search technique or pattern, one of the most commonly used methods to solve a variety of problems. By the end, you should: Be familiar with the binary search algorithm. See how it's used in interviews. Understand its complexities. Binary Sea...

8. LESSON

A Close Look at Merging Intervals

Objective: In this lesson, we'll cover this concept, and focus on these outcomes: You'll learn what merging intervals means. We'll show you how to solve similar time-based, or interval-based problems in programming interviews. Let's study the Merge Intervals algorithm which is used to...

9. LESSON

Fundamental Sorting Algorithms: Bubble and Insertion

This tutorial is about two fundamental, and basic, sorting algorithms. If you are new to sorting, I'd recommend you come up with your own algorithm for sorting arrays first, and then compare it with these algorithms. These fundamental sorting techniques give you important insights into: How to sort arrays How you can improve an algorit...

10. LESSON

Merge Sort vs. Quick Sort vs. Heap Sort

In this tutorial, we are going to discuss three O (n log n) sorting techniques, their implementations, and how we derive their runtimes. The learning objectives of this tutorial are as follows: You will be able to apply the Divide-and-Conquer approach to different sorting methods. You will be able t...

11. LESSON

Prefix, Infix, Postfix Notation and Prefix Sums

There are a few different ways to write arthimetic expressions in computer science. Infix, Postfix and Prefix notations are three different but equivalent ways of doing this and achieving the same result in the end. In this tutorial, we are going to explain these three, give some examples of their usage, and dig into the `Prefix Sums algorit...

12. LESSON

Cycling Through Cycle Sort

In this lesson, we are going to study the Cycle Sort algorithm, which is one of the less commonly used sorting algorithms, but surprisingly useful in programming interviews. The Theory Th...

13. CHALLENGE

Max Product of Three Numbers

Given an unsorted array of integers, can you write a method maxProductOfThree(unsorted: array) to find the largest product from three of the numbers? For example, given the following array: [-1, 9, 22, 3, -15, -7] The largest product of three numbers is 2310. This results from -15 * -7 * 22. <img src="https://storage.goo...

14. CHALLENGE

Sorted Two Sum

The setup is the same as Two Sum-- you're given an array of numbers, and a "goal" number. Write a method to return an array of the indexes of the two elements in the array that sum up to the goal. If there are no such elements, return an empty array. The caveat here is that the numbers are guaranteed to...

15. CHALLENGE

How Out of Order

This was submitted by user Hackleman. Determine how "out of order" a list is by writing a function that returns the number of inversions in that list. Two elements of a list L, L[i] and L[j], form an inversion if L[i] j. <img src="https://storage.googleapis.com/algodailyrandomassets/curriculum/me...

16. CHALLENGE

Dutch National Flag Problem

This problem is named the "Dutch national flag problem" because the flag of the Netherlands is comprised of the colors red, white, and blue in separate parts. Although we won't be using colors, the premise of the challenge is to develop a sorting algorithm that performs some form of separations of three kinds of elements. <img s...