MergeSort in Dart — Sorting Algorithms

Tomic Riedel
4 min readFeb 20, 2022

MergeSort is one of the most popular sorting algorithms. In this article you will learn about the features of MergeSort and how to implement the sorting algorithm in Dart. Of course, this code will also be explained.

If you want to follow me further in this series and are interested in other articles, then I recommend you to follow me.

Enjoy the read!

Introduction

To explain MergeSort in a basic way, we will use a card example. We imagine a deck of cards, where the cards have numbers from 1–10. We now want to sort the shuffled deck of cards.

To begin with, we divide the deck in half. Then we divide this half again. We do this until each card stands alone.

Now we compare two adjacent cards. If the right one is bigger, it goes to the beginning and vice versa. Then we compare two adjacent piles again and so on.

Properties

First we look at the time complexity of MergeSort. We have given an array with n=8 elements. So 3 levels of divisions are needed. We denote these as d.

Source: https://www.javatpoint.com/daa-merge-sort

--

--

Tomic Riedel

Sharing the process of building a portfolio of apps to make people more productive.