1.

What is the recurrence relation for the linear search recursive algorithm?(a) T(n-2)+c(b) 2T(n-1)+c(c) T(n-1)+c(d) T(n+1)+cI got this question in semester exam.Query is from Searching in portion Searching of Data Structures & Algorithms II

Answer»

Right answer is (c) T(n-1)+c

Best explanation: After each call in the RECURSIVE algorithm, the SIZE of n is REDUCED by 1. Therefore the OPTIMAL solution is T(n-1)+c.



Discussion

No Comment Found

Related InterviewSolutions