Problem:
Suppose that you have two algorithms A and B that
Question- Solve the problem. Algorithm A has worst case running time TA(n) =2n^2 ? 2n + 1 and Algorithm B has worst case running time TB(n) = n^2 + n ? 1.
Required:
Part 1- Show that both TA(n) and TB(n) are in O(n^2).
Part 2- Show that TA(n) = 2n^2 + O(n) and TB(n) = n^2 + O(n).
Part 3- Explain which algorithm is preferable.