+1 vote
in Data Structures & Algorithms II by (110k points)
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)+c

I got this question in semester exam.

Query is from Searching in portion Searching of Data Structures & Algorithms II

1 Answer

+1 vote
by (614k points)
selected by
 
Best 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.

Related questions

Welcome to TalkJarvis QnA, a question-answer community website for the people by the people. On TalkJarvis QnA you can ask your doubts, curiosity, questions and whatever going in your mind either related to studies or others. Experts and people from different fields will answer.

Categories

...