It falls in case II of the Master Method and the solution of the recurrence is θ(Nlog(N)). The time complexity of Merge Sort isθ(Nlog(N)) in all 3 cases (worst, average, and best) as merge sort always divides the array into two halves and takes linear time to merge two halves.Īuxiliary Space: O(n), In merge sort all elements are copied into an auxiliary array. The above recurrence can be solved either using the Recurrence Tree method or the Master method. Merge Sort is a recursive algorithm and time complexity can be expressed as following recurrence relation. Time Complexity: O(N log(N)), Sorting arrays on different machines.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |