CmSc 250 Intro to Algorithms


Mathematical Review

Exam-like problems


  1. Basic algebra
  2. (a + b)2 = a2 + 2ab + b2

    (a - b)2 = a2 - 2ab + b2

    a2 - b2 = (a + b)(a - b)

    a/x + b/y = (ay + bx)/xy

  3. Exponents
  4. Xn = XXX…..X , n times

    X0 = 1 by definition

    XaXb = X(a+b)

    Xa / Xb = X(a-b) Prove that: X-n = 1 / Xn

    (Xa )b = Xab

  5. Logarithms
  6. logaX is defined for a > 0, X > 0

    Definition: logaX = Y ó aY = X

    E.G: log28 = 3; 23 = 8

    loga1 = 0 because a0 = 1

    logX means log2X

    lgX means log10X

    lnX means logeX, where e is the natural number

    loga(XY) = logaX + logaY

    loga(X/Y) = logaX - logaY

    loga(Xn) = nlogaX

  7. Series
  8. Σ 2i = 2(N+1) - 1 can be proved by induction
    i=0 to N

    Σ Ai = (A(N+1) - 1)/(A - 1)
    i=0 to N

  9. Limits of functions
  10. lim(n) = ∞, n → ∞

    lim(na) = ∞, n → ∞, a > 0

    lim(1/n) = 0, n → ∞

    lim(1/(na) = 0, n → ∞, a > 0

    lim(log(n)) = ∞, n → ∞

    lim(an) = ∞, n → ∞, a > 0

     

    lim( f(x) + g(x) ) = lim( f(x) ) + lim( g(x) )

    lim( f(x)*g(x) ) = lim( f(x) )*lim( g(x) )

    lim( f(x)/g(x) ) = lim( f(x) )/lim( g(x) )

    lim( f(x)/g(x) ) = lim( f '(x) / g'(x) ) (L'Hopital's rule, applied when both limits are 0, or both are infinity)

    Examples:

    lim(n/ n2 ) = 0, n → ∞,

    lim(n2 / n) = ∞, n → ∞

    lim(n2 / n3 ) = 0, n → ∞,

    lim(n3 / n2 ) = ∞, n → ∞

    lim(n/((n+1)/2) = 2.

    Derivatives:

    (logan)' = (1/n) logae

    (an)' = (an)ln(a)

  11. Recursive definitions
  12. Basic idea: To define objects, processes and properties in terms of simpler objects,
    simpler processes or properties of simpler objects/processes.

    A recursive definition consists of:

    1. Terminating rule - defining the object explicitly.
    2. Recursive rules - defining the object in terms of a simpler object.

    Examples of recursive definitions:

    1. Factorials: f(n) = n!

      Rule 1. f(0) = 1 i.e. 0! = 1
      Rule 2. f(n) = n * f(n-1) i.e. n! = n * (n-1)!

    2. Fibonacci numbers: 1, 1, 2, 3, 5, 8, ….
    3. Rule 1.1 F(0) = 1
      Rule 1.2 F(1) = 1

      Rule 2. F(k+1) = F(k) + F(k-1)

      Note: Here, there are two terminating rules.
  13. Proofs
    1. Proof by Induction
    2. We use proof by induction when our claim concerns a sequence of cases, which can be numbered. An example is the equality

      S(N) = Σ 2i = 2(N+1) - 1
               i=0 to N

      The cases here depend on N:

      1. N = 0: S(0) = 20

      2. N = 1: S(1) = 20 + 21

      3. N = 2: S(2) = 20 + 21 + 22

      …..

      N = k: S(k) = 20 + 21 + 22 + ….. + 2k

      ….

      Steps of proof by induction:

      1. Inductive base: Show that the claim is true for the smallest case, usually k = 0 or k = 1.
      2. Proof under inductive hypothesis:
        1. Assume that the claim is true for some k
        2. Prove that the claim is true for k+1

      EXAMPLE:

      Prove by induction that

      S(N) = Σ 2i = 2(N+1) - 1, for any integer N ≥ 0
                i=0 to N

      1. Inductive base: Show that the formula is true for N = 0.
      2. When substituting N=0 in the formula, we get

        S(0) = Σ 2i = 2(0+1) - 1 = 2 - 1 = 1
                  i=0 to 0

        Is this true?

        Solution: By definition of S, S(0) = 20 = 1

        By the formula we have: 2(0+1) - 1 = 21 - 1 = 1

        Right sides are equal, hence the formula is true for N = 0

        S(0) = Σ 2i = 2(0+1) - 1 = 1
                  i=0 to 0

      3. Proof under inductive hypothesis: Assume that the formula is true for some k and prove that under this assumption the formula is true for k+1
      4. We assume that S(k) is equal to 2(k+1) - 1, i.e.

        S(k) = Σ 2i = 2(k+1) - 1
                  i=0 to k

        Now we shall show that

        S(k+1) = Σ 2i = 2(k+2) - 1
                  i=0 to k+1

        We use the defining property of this particular sequence of sums: S(k+1) = S(k) + 2(k+1) and we substitute S(k) with its equal expression from our assumption.

        Thus we have:

        S(k+1) = S(k) + 2(k+1) =

        = 2(k+1) - 1 + 2(k+1) =

        = 2. 2(k+1) - 1 =

        = 21+(k+1) - 1 =

        = 2(k+2) - 1

        This completes our proof: We conclude that

        S(N) = Σ 2i = 2(N+1) - 1, for any integer N ≥ 0
                 i=0 to N

    3. Proof by counterexample
    4. Used when we want to prove that a statement is false.
      Types of statements: a claim that refers to all members of a class.

      EXAMPLE:

      The statement "all odd numbers are prime" is false.
      A counterexample is the number 9: it is odd and it is not prime.

    5. Proof by contradiction
    6. Assume that the statement is false, i.e. its negation is true.
      Show that the assumption implies that some known property is false - this would be the contradiction.

      EXAMPLE:

      Prove that there is infinite number of primes.

      Proof:

      1. Assume that the statement is false, i.e. the number of primes is finite.
      2. Consequences of that assumption:
      3. There is a prime number that is the largest one - Pk
        Let P1, P2,.. Pk are all the prime numbers, ordered.
        Consider the number N = P1*P2*….Pk   +  1
        ( N is the product of all prime numbers plus one)
        N is greater than Pk, and following our assumption N is not prime.
        All non-prime numbers are equally divided by some prime number
        (This is a known property)

        Hence N should be equally divided by at least one of P1 through Pk.

      4. Contradiction:
      5. We can see that none of the prime numbers P1 through Pk divides N equally - there is a remainder of 1. This is the contradiction.

    7. Proof by contraposition
    8. Based on the equivalence of P → Q and ~Q → ~P
      In order to prove P → Q, we prove ~Q → ~P

      Example: Prove that if the square of an integer is odd, then the integer is odd.

      Proof: We will prove that if an integer is even, then its square even. We can do this using direct proof.

      Let m be an even integer. This means that m can be represented as a multiple of 2: m = 2k

      m2 = (2k)2 = 4k2 = 2.(2k2) Therefore m2 can be represented as a multiple of 2, therefore m2 is even.

      We have proved that if an integer is even, its square is even. This is equivalent to: If the square of an integer is not even (i.e. it is odd) then the integer is not even (i.e. the integer is odd).


Exam-like problems

Consider the following functions:

n2, 2n, nlogn, n6 + n2, n4, n6 - n3, 4n, n, nn

Find the limit of the quotient of any two functions


Back to Contents page
Created by Lydia Sinapova