Introduction to Algorithms
Week 1: Notes

pronunciation

Note how these are pronounced in English:

x² – "x squared"

x³ – "x cubed"

x⁴ – "x to the fourth"

x100"x to the one hundredth"

xn"x to the n" (or, less commonly, "x to the nth")

a / b – "a over b"

z – "zee" (American English) or "zed" (British)

π – "pie"

powers of 10

10-9 = 1 / 1,000,000,000, prefix = nano (e.g. nanosecond)

10-6 = 1 / 1,000,000, prefix = micro (e.g. microsecond)

10-3 = 1 / 1,000, prefix = milli (e.g. millisecond)

100 = 1

103 = 1,000 = one thousand, prefix = kilo (e.g. kilogram = 1000 g)

10⁶ = 1,000,000 = one million, prefix = mega, (e.g. megawatt)

10⁹ = 1,000,000,000 = one billion, prefix = giga (e.g. gigawatt)

1012 = 1,000,000,000,000 = one trillion, prefix = tera (e.g. terabyte)

powers of 2

You should know by heart:

The fact that 210103 allows you to convert between powers of 2 and 10 easily, at least approximately. For example, 226 = 26 · 220 = 64 M ≈ 64,000,000.

exponentiation

You should be familiar with these identities:

logarithms

You should be familiar with these identities:

integers

integers = ℤ

, -2, -1, 0, +1, +2, +3, ...

natural numbers = non-negative integers = ℕ

= 0, 1, 2, 3, 4, ...

The mathematical study of the integers is called number theory.

divisibility

Let a, d, q ∈ ℤ. If a = dq then a is divisible by d. a is a multiple of d. d is a factor of a.


Example: What are all factors of 6?

1, 2, 3, 6, -1, -2, -3, -6


(Division Theorem) For any a, b ∈ ℤ with b > 0, there exist unique q, r ∈ℤ such that

a = q · b + r and 0 ≤ r < b


We write

q = quotient of a and b, denoted by a div b
r = remainder, denoted by a mod b


For example, if a = 17 and b = 5, then

q = 3
r = 2
17 = 3 · 5 + 2

So 17 div 5 = 3, and 17 mod 5 = 2.


Or if a = -17 and b = 5, then

q = -4
r = 3
-17 = -4 · 5 + 3

So -17 div 5 = -4, and -17 mod 5 = 3.


For any a ∈ ℤ,

a mod 2 = 0 <==> a is even
a mod 2 = 1 <==> a is odd


For any a ∈ ℤ, a div 1 = a, and a mod 1 = 0.