MAD101 Assignment 2
MAD101 Assignment 2
1. A palindrome is a string that reads the same forward and backward. De-
scribe an algorithm for determining string of n characters is a palindrome.
2. Describe an algorithm that determines whether a function from a finite
set of integers to another finite set of integers is onto.
3. Determine whether each of the functions 2n+1 and 22n is O(2n ).
4. Find the least integer n such that f (x) is O(xn ) for each of these functions.
(a) f (x) = 2x2 + x3 log x
(b) f (x) = 3x5 + (log x)4
(c) f (x) = (x4 + x2 + 1)/(x4 + 1)
(d) f (x) = (x3 + 5 log x)/(x4 + 1)
5. Show that for all real numbers a and b with a > 1 and b > 1, if f (x) is
O(logb x), then f (x) is O(loga x).
6. Evaluate these quantities.
(a) 13 mod 3
(b) −97 mod 11
(c) 155 mod 19
(d) −221 mod 23
7. Show that if a, b, c, and m are integers such that m ≥ 2, c > 0, and a ≡ b(
mod m), then ac ≡ bc( mod mc).
8. Find each of these values.
(a) (192 mod 41) mod 9
(b) (323 mod 13)2 mod 11
(c) (73 mod 23)2 mod 31
(d) (212 mod 15)3 mod 22
9. Use the Euclidean algorithm to find
1
(a) gcd(1, 5)
(b) gcd(100, 101)
(c) gcd(111, 201)
10. Prove that if n is a positive integer such that the sum of the divisors of n
is n + 1, then n is prime
11. Find the output of the recursive algorithm if input n = 5.
13. Find a recursive definition for the set of positive integers NOT divisible
by 3.