Step-by-Step Explanation
We are given the recurrence relation for \(n > 3\):
\(T(n)=T(n-1)+T(n-2)-T(n-3)\)
Let's substitute the options to find which relation produces a constant time complexity, \(O(1)\).
Testing Option A: \(T(1) = T(2) = T(3) = k\) (where \(k\) is a constant)
• For \(n = 4\):
\(T(4)=T(3)+T(2)-T(1)=k+k-k=k\)
• For \(n = 5\):
\(T(5)=T(4)+T(3)-T(2)=k+k-k=k\)
• For \(n = 6\):
\(T(6)=T(5)+T(4)-T(3)=k+k-k=k\)
By induction, \(T(n) = k\) for all \(n\). Since the running time stays completely fixed at a constant value \(k\) regardless of the size of \(n\), the order of the algorithm is constant (\(O(1)\)).
Why the other options are incorrect:
If we try any other relationship, the values will create a linear growth (\(O(n)\)). For example, testing Option B with values that satisfy \(T(1) + T(3) = 2 \cdot T(2)\) (such as \(T(1)=1, T(2)=2, T(3)=3\)):
• \(T(4) = 3 + 2 - 1 = 4\)
• \(T(5) = 4 + 3 - 2 = 5\)
This results in \(T(n) = n\), which means the time complexity is linear (\(O(n)\)) rather than constant.