Placeholder image

Merge sort a simple comparison-based algorithm that is based on sorting a vector one element at the time, and maintaining the sorted part of the vector while finding the location for next element in that sorted part Conceptually, a merge sort works as follows:

Divide the unsorted list into n sublists, each containing 1 element (a list of 1 element is considered sorted).
Repeatedly merge sublists to produce new sorted sublists until there is only 1 sublist remaining. This will be the sorted list.

The average case performance of merge sort is O(n log n)

The algorithm:

Graph will be partitioned on halves indicating what lvl of recursion it is doing
After it gets into the last lvl (where 1 element is left), merging of halves starts
Light green color indicates first element of left half
Dark green indicates first element of right half
Algorithm is provided with step by step explanation

There is an issue possible with visualization glitching due to incorrect data input. Javascript reads a string from input window and it separates it into array of ints. If spaces with commas are not placed correctly, wrong data may be generated. So we strongly encourage users to separate each value with comma and one space