Estimating Running Times
Algorithm arrayMax requires 5n – 2 primitive operations in the worst case
- best case requires 4n – 1 operations (why?)
Define:
- a … time taken by the fastest primitive operation
- b … time taken by the slowest primitive operation
Let T(n) be worst-case time of arrayMax . Then
a·(5n - 2) ≤ T(n) ≤ b·(5n - 2)
Hence, the running time T(n) is bound by two linear functions
|