226 Solutions to Exercises some constant c and all sufficiently large n. Now clog n = log nC and log is an increasing function, so log (An + B) ~ clogn ~ An + B ~ nCo But An + B ~ (A + B)n ~ n2 for n > A + B so c = 2, works. 23. Since n = ab with 1 < a, b < n implies either a ~ ..;n or b ~ ..;n, n is prime if does not have a proper factor less than or equal to ..;n. So, for each integer k, 1 < k < r Vnl, use the Euclidean algorithm to determine if gcd (k, n) = 1. As shown in Problem 19, this algorithm requires 0 (In k) = O(ln..;n) = O(ln n) divisions. The integer n is prime if and only if gcd(k, n) = 1 for all such k. The entire procedure is 0 ( ..;n In n). 24. [BB] Since n! = n(n -1)(n -2) .. ·3·2.1 < nn, logn! ~ n log n. With c = 1, no = 1 in Definition 8.2.1, we see that logn! = O(n log n) as required. 25. (a) If a = (akak-l ... a2alaoh, then the base 2 digits ao, al, ... , ak are the remainders given by the following process of successive divisions by 2: a 2qo + ao qo 2ql + al ql 2q2 + a2 The process terminates when qk = O. Assuming that each line here is a single operation, the number of operations required is k + 1.
This is the end of the preview.
access the rest of the document.