What will be the recurrence relation of the code of recursive bubble sort?

What will be the recurrence relation of the code of recursive bubble sort?
A. T(n) = 2T(n/2) + n
B. T(n) = 2T(n/2) + c
C. T(n) = T(n-1) + n
D. T(n) = T(n-1) + c
 
Answer: c
Explanation: The recurrence relation of the code of recursive bubble sort is T(n) = T(n-1) + n. It can be solved by the method of substitution and is found to be equal to n$^{2}$.
 

Tìm kiếm

Back
Top