<aside> 💡 Divide to conquer

</aside>

Merge


Fundamental for the merge sort to work.

It combines two ordered arrays into another already ordered array. It applies the parting multiple times in order to order an array.

Efficiency


This algorithm’s time complexity is not based on its worst-case scenario and that is because, it is always O(N log N), making sure it’s efficient in every case.

Variables


“i” controls the index of the first collection.

“j” controls the index of the second collection.

“k” controls the index of the final collection.

Resulting Array


The length of the resulting array is going to be the sum of the length of the other two arrays.

See more about it