1.

What will be the recurrence relation of the code of recursive selection 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) + cI have been asked this question during an interview for a job.This key question is from Recursion topic in section Recursion of Data Structures & Algorithms II

Answer»

Right option is (c) T(n) = T(n-1) + n

Explanation: Function to find the minimum element index takes n time.The RECURSIVE call is made to one less element than in the PREVIOUS call so the OVERALL recurrence relation becomes T(n) = T(n-1) + n.



Discussion

No Comment Found

Related InterviewSolutions