Merge Sort - Time Complexity
Time Complexity of Merge Sort
Algorithm:
MergeSort(left,
right){
If(left < right){
Mid=(left+right)/2
MergeSort(left,mid)
MergeSort(mid+1, right)
Merge(left,mid,right)
}
}
The algorithm shows, MergeSort function devices the entire array into two parts in one iteration. The Programme will terminate when it comes to One element in the array. The following diagram shows how it performs.
Comments
Post a Comment