Merge Sort🎂

Tehleel Mir
Mar 10, 2022

Merge sort is a sorting algorithm used to sort an array/list.

Time Complexity
The time complexity of the merge case is O(n log n) in all the cases.

Explanation
In merge sorted we use the divide and conquer method to divide the whole list into sub-partitions until each partition only contains one element, so that takes O(log n) time. Second, on each level of the Recursion tree, we perform the merge operation that goes through the n elements in the list and sorted them, so that takes O(n). So combining both operations we get O(n log n).

Code

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

No responses yet