Exercise 2: Proving f(n) = 2n + 7 Is Theta(n) — Possible Solution ==================================================================== GIVEN ------------------------------ f(n) = 2n + 7 STEP 1: THE O(n) BOUND, c=3 ------------------------------ Testing f(n) <= 3n at successive values of n: n=6: f(6) = 2(6)+7 = 19. 3n = 18. 19 <= 18? NO. n=7: f(7) = 2(7)+7 = 21. 3n = 21. 21 <= 21? YES (exactly equal). So the smallest n0 for which f(n) <= 3n holds for all n >= n0 is: n0 = 7 STEP 2: THE OMEGA(n) BOUND ------------------------------ Using c=2: f(n) = 2n + 7 >= 2n holds for EVERY n >= 1, since the extra +7 term is always positive and can only make the left side larger, never smaller, than 2n. So: Omega(n) holds with c=2, n0=1 STEP 3: CONCLUDING THETA(n) ------------------------------ Since both f(n) = O(n) (with c=3, n0=7) and f(n) = Omega(n) (with c=2, n0=1) are proven with valid constants, per this chapter's own definition: f(n) = Theta(n) WHY THIS WORKS AS AN ANSWER ------------------------------ Both bounds are proven separately with explicit, verified constants - the O(n) bound's n0 is found by checking successive integers until the inequality first holds, and the Omega(n) bound is shown to hold trivially for all n due to the always-positive +7 term - and the Theta conclusion is drawn only after both individual proofs are established, exactly per this chapter's own definition of Theta as requiring both O and Omega simultaneously.