in Algorithms
1,144 views
0 votes
0 votes
what is the recurrence relation for merge sort?
in Algorithms
by
1.1k views

1 comment

T(n)= 2T(n/2) +Theta(n)
1
1

3 Answers

0 votes
0 votes
First merge sort for half array(1to m) that takes T(n/2)

Second merge sort for last half array(m+1to n)

Final phase merging them in O(n) time

So total time complexity=2T(n/2)+O(n/2)

=O(nlogn)
0 votes
0 votes
Reccurrence relation for merge sort is T(n)=2T(n/2)+O(n)
0 votes
0 votes
T(n) =2T(n/2) + O(n)

T(1) = 1

Because in mergesort function we call two time mergesort and at last

we call merge procedure , merge procedure take O(n) and each time we

divide array in half .