Chapter 3
The Fundamentals:
Algorithms The Integers
3.1- Algorithms
1.
3.1- Algorithms
2.
3.1- Algorithms
3.
3.2- The Growth of Functions
4. Determine whether each of these functions is O(x):
3.2- The Growth of Functions
4. Determine whether each of these functions is O(x):
5. Determine whether each of these functions is O x :
2
3.2- The Growth of Functions
6. Find the least integer n such that f(x) is
functions:
for n
O x of these
each
3.2- The Growth of Functions
7. Find the least integer n such that f(x) is
functions:
for
n
O x of these
each
1 log x x x log x x 2 2 x x !
O x4 n 4
O x n5
5
O x0 n 0
O x n 1
1
x 3 5log x x 3 5 x 3 6 x 3 6
x4 1
x4
x4
x
6 x
1
3.2- The Growth of Functions
8. Determine whether x 3 is O g x for each of these
functions g x .
a) g x x 2
b) g x x 3
c) g x x x
2 3
d ) gx x x 2 4
e) g x 3 x f ) g x x3 / 2
3.2- The Growth of Functions
9. Give a big-O estimate for each of these functions. For the
function g in your estimate that f (x) is O(g(x)), use a simple
function g of the smallest order.
3.2- The Growth of Functions
10. Give a big-O estimate for each of these functions. For
the function g in your estimate that f (x) is O(g(x)), use a
simple function g of the smallest order.
3.4- The Integers and Division
11. What are the quotient and remainder when
a) 19 is divided by 7? b) −111 is divided by 11?
c ) 3 is divided by 5? d) −1 is divided by 3?
3.4- The Integers and Division
12. Find a div m and a mod m when
a) a = 228, m = 119. c) a = −10101, m = 333.
b) a = 9009, m = 223. d) a = −765432, m = 38271.
3.4- The Integers and Division
13. Decide whether each of these integers is congruent to
5 modulo 17.
a) 80 b) 103 c) −29 d) −122
3.4- The Integers and Division
14. Find the integer a such that
a) a ≡ −15 (mod 27) and −26 ≤ a ≤ 0.
b) a ≡ 24 (mod 31) and −15 ≤ a ≤ 15.
c) a ≡ 99 (mod 41) and 100 ≤ a ≤ 140.
3.4- The Integers and Division
15. Find each of these values.
a) (−133 mod 23 + 261 mod 23) mod 23
b) (457 mod 23 · 182 mod 23) mod 23
3.5- Primes and Greatest
Common Divisors
3.5 Primes and Greatest Common Divisors
16. Find the prime factorization of each of these integers.
a) 126 b) 1001 c) 10!
3.5 Primes and Greatest Common Divisors
17. Determine whether the integers in each of these sets are
pairwise relatively prime.
a) 11, 15, 19
b) 14, 15, 21
c) 12, 17, 31, 37
d) 7, 8, 9, 11
3.5 Primes and Greatest Common Divisors
18. What are the greatest common divisors of these pairs
of integers?
7 3 3 11 4 9
a ) 3 .5 .7 , 2 .3 .5
b) 11.13.17, 29.37.55.73
c) 1111, 0
3.5 Primes and Greatest Common Divisors
19. What are the least common multiple of these pairs of
integers?
a ) 37 .53.73 , 211.34.59
9 7 5 3
b) 11.13.17, 2 .3 .5 .7
c) 1111, 0
3.5 Primes and Greatest Common Divisors
7 8 2 11
20. If the product of two integers is 2 3 5 7 and their greatest
3 4
common divisor is 3 5 , what is their least common multiple?
2
3.6- Integers and Algorithms
3.6- Integers and Algorithms
21. Convert the decimal expansion of each of these integers
to a binary expansion.
a) 231 b) 4532 c) 97644
3.6- Integers and Algorithms
22. Convert the binary expansion of each of these integers
to a decimal expansion.
a ) 1 11112 c) 1 0101 01012
b) 10 0000 00012 d ) 110 1001 0001 0000 2
3.6- Integers and Algorithms
23. Convert the octal expansion of each of these integers
to a binary expansion.
a ) 572 8 c) 4238
b) 1604 8 d ) 24718
3.6- Integers and Algorithms
24. Convert the binary expansion of each of these integers
to an octal expansion.
a ) 1111 01112 b) 111 0111 0111 01112
3.6- Integers and Algorithms
25. Convert the hexadecimal expansion of each of these
integers to a binary expansion.
a ) 80 E 16 b) 135 AB 16
3.6- Integers and Algorithms
26. Find the sum 101101 + 101100 in binary representation.