Question #54: Which of the following recursive equation holds true for the linear search algorithm?
Options:
- T(n) = T(n-1) + 1
- T(n) = T(n/2) + 1
- T(n) = 2T(n/2) + 1
- T(n) = T(log(n)) + 1
Solution: In every step while searching linearly, we eliminate one element from the list. Hence the problem T(n) reduces to T(n-1). Therefore, option 1 is correct.
