Recurrence relation for ternary search

5k Views Asked by At

The recurrence relation of ternary search is T(n)= T(n/3) + 4, How 4 is in recurrence relation, since in ternary search it's log to the base 3 N, so only 3 partitions should be there ?

1

There are 1 best solutions below

0
Yola On

Recurrence relation for ternary search is T(n) = T(n/3) + O(1) or even T(n) = T(2n/3) + O(1). The constant hidden in this O(1) depends on concrete implementation and how analysis was conducted. It could be 4 or 3, or some other value. Applying case 2 of Master theorem you still have O(log n).