Exercise 2: Estimating O(n!) Running Time at n=15 — Possible Solution ==================================================================== GIVEN ------------------------------ 1 billion (1e9) operations per second, n = 15 STEP 1: TOTAL OPERATIONS ------------------------------ 15! = 1,307,674,368,000 (~1.31 x 10^12 operations) STEP 2: CONVERTING TO TIME ------------------------------ seconds = 1.31 x 10^12 / 1 x 10^9 = 1,307.7 seconds STEP 3: CONVERTING TO A HUMAN-READABLE UNIT ------------------------------ 1,307.7 seconds / 60 = 21.79 minutes RESULT ------------------------------ An O(n!) algorithm at n=15 would take approximately 21.8 minutes at 1 billion operations per second. COMPARING TO THE O(2^n) ESTIMATE ------------------------------ This exercise's operation count (~1.31 x 10^12 at n=15) is almost identical in magnitude to Exercise 1's O(2^n) operation count (~1.10 x 10^12 at n=40) - roughly the same total amount of work. But 15! reached that magnitude at n=15, while 2^40 needed n=40 to reach a comparable size - factorial growth needed less than half the input size to produce roughly the same total operation count. This confirms factorial growth is dramatically faster than exponential growth: per this chapter's own tables, n! overtakes 2^n by a wide and rapidly growing margin as n increases further past this point. WHY THIS WORKS AS AN ANSWER ------------------------------ The total operation count and time estimate are computed using the exact same method as Exercise 1, and the comparison between the two algorithms is made concrete by noting how much SMALLER an n was needed for the factorial case to reach a similar total operation count, rather than just asserting factorial growth is "faster" in the abstract.