Month: February 2021

  • Merge Sort Algorithm

    Merge Sort Algorithm

    Basics

    Merge Sort is a divide and conquer algorithm.

    The algorithm is based on the principle that a one-element algorithm is sorted a priori.

    The algorithm starts by recursively dividing the list into smaller ones. This process is called “partitioning”. This continues until the length of the sublists becomes 1.

    Next, the elements of the list are merged with a simultaneous comparison of the elements. This process is called “merging”.

    The video below explains well how the algorithm works.

    This diagram shows how the algorithm works on the example of the list

    [10, 5, 7, 4, 1, 2, 5, 18]

    Sample code

    Below you will get a link to GitHub repo with Kotlin, Java, and Python source code

    Download it from github