Climbing an Infinite Ladder - PowerPoint PPT Presentation

1 / 75
About This Presentation
Title:

Climbing an Infinite Ladder

Description:

Climbing an Infinite Ladder Suppose we have an infinite ladder: We can reach the first rung of the ladder. If we can reach a particular rung of the ladder, – PowerPoint PPT presentation

Number of Views:114
Avg rating:3.0/5.0
Slides: 76
Provided by: RichardS183
Learn more at: http://www.cs.gsu.edu
Category:

less

Transcript and Presenter's Notes

Title: Climbing an Infinite Ladder


1
Climbing an Infinite Ladder
  • Suppose we have an infinite ladder
  • We can reach the first rung of the ladder.
  • If we can reach a particular rung of the
    ladder,
  • then we can reach the next rung.

From (1), we can reach the first rung. Then by
applying (2), we can reach the second rung.
Applying (2) again, the third rung. And so on.
We can apply (2) any number of times to reach any
particular rung, no matter how high up.
This example motivates proof by mathematical
induction.
2
Principle of Mathematical Induction
  • Principle of Mathematical Induction To
    prove that P(n) is true for all positive integers
    n, we complete these steps
  • Basis Step Show that P(1) is true.
  • Inductive Step Show that P(k) ? P(k 1) is
    true for all positive integers k.
  • To complete the inductive step, assuming the
    inductive hypothesis that P(k) holds for an
    arbitrary integer k, show that must P(k 1) be
    true.
  • Climbing an Infinite Ladder Example
  • BASIS STEP By (1), we can reach rung 1.
  • INDUCTIVE STEP Assume the inductive hypothesis
    that we can reach rung k. Then by (2), we can
    reach rung k 1.
  • Hence, P(k) ? P(k 1) is true for all
    positive integers k. We can reach every rung on
    the ladder.

3
Important Points About Using Mathematical
Induction
  • Mathematical induction can be expressed as the
    rule of inference
  • where the domain is the set of positive
    integers.
  • In a proof by mathematical induction, we dont
    assume that P(k) is true for all positive
    integers! We show that if we assume that P(k) is
    true, then P(k 1) must also be true.
  • Proofs by mathematical induction do not always
    start at the integer 1. In such a case, the basis
    step begins at a starting point b where b is an
    integer.

(P(1) ? ?k (P(k) ? P(k 1))) ? ?n P(n),
4
Proving a Summation Formula by Mathematical
Induction
  • Example Show that
  • Solution
  • BASIS STEP P(1) is true since 1(1 1)/2 1.
  • INDUCTIVE STEP Assume true for P(k).
  • The inductive hypothesis is
  • Under this assumption,

Note Once we have this conjecture, mathematical
induction can be used to prove it correct.
5
Proving Inequalities
  • Example Use mathematical induction to prove
    that n lt 2n for all positive integers n.
  • Solution Let P(n) be the proposition that n lt
    2n.
  • BASIS STEP P(1) is true since 1 lt 21 2.
  • INDUCTIVE STEP Assume P(k) holds, i.e., k lt 2k,
    for an arbitrary positive integer k.
  • Must show that P(k 1) holds. Since by the
    inductive hypothesis, k lt 2k, it follows that
  • k 1 lt 2(k 1) 2k 21 2 2k
    2k1
  • Therefore n lt 2n holds for all positive
    integers n.

6
(No Transcript)
7
Strong Induction and Well-Ordering
  • Section 5.2

8
Strong Induction
  • Strong Induction To prove that P(n) is true for
    all positive integers n, where P(n) is a
    propositional function, complete two steps
  • Basis Step Verify that the proposition P(1) is
    true.
  • Inductive Step Show the conditional statement
    P(1) ? P(2) ? ? P(k) ? P(k 1)
    holds for all positive integers k.

Strong Induction is sometimes called the second
principle of mathematical induction or complete
induction.
9
Strong Induction and the Infinite Ladder
  • Strong induction tells us that we can reach all
    rungs if
  • We can reach the first rung of the ladder.
  • For every integer k, if we can reach the first k
    rungs,
  • then we can reach the (k 1)st rung.
  • To conclude that we can reach every rung by
    strong induction
  • BASIS STEP P(1) holds
  • INDUCTIVE STEP Assume P(1) ? P(2) ? ? P(k)
  • holds for an arbitrary integer k, and show
    that
  • P(k 1) must also hold.
  • We will have then shown by strong induction that
    for every positive integer n, P(n) holds, i.e.,
    we can
  • reach the nth rung of the ladder.

10
Which Form of Induction Should Be Used?
  • We can always use strong induction instead of
    mathematical induction. But there is no reason to
    use it if it is simpler to use mathematical
    induction.
  • In fact, the principles of mathematical
    induction, strong induction, and the
    well-ordering property are all equivalent.
  • Sometimes it is clear how to proceed using one of
    the three methods, but not the other two.

11
Proof using Strong Induction
  • Example
  • Prove that every amount of postage of 12 cents
    or more can be formed using just 4-cent and
    5-cent stamps.

12
Proof using Strong Induction
  • Solution
  • Let P(n) be the proposition that postage of n
    cents can be formed using 4-cent and 5-cent
    stamps.
  • BASIS STEP P(12), P(13), P(14), and P(15) hold.
  • P(12) uses three 4-cent stamps.
  • P(13) uses two 4-cent stamps and one 5-cent
    stamp.
  • P(14) uses one 4-cent stamp and two 5-cent
    stamps.
  • P(15) uses three 5-cent stamps.
  • INDUCTIVE STEP
  • The inductive hypothesis states that P(j) holds
    for 12 j k, where k 15. Assuming the
    inductive hypothesis, it can be shown that P(k
    1) holds.
  • Using the inductive hypothesis, P(k - 3) holds
    since k - 3 12. To form postage of k 1
    cents, add a 4-cent stamp to the postage for k -
    3 cents.
  • Hence, P(n) holds for all n 12.

13
Well-Ordering Property
  • Well-ordering property Every nonempty set of
    nonnegative integers has a least element.
  • The well-ordering property can be used directly
    in proofs, as the next example illustrates.
  • Definition A set is well ordered if every subset
    has a least element.
  • N is well ordered under .
  • The set of finite strings over an alphabet using
    lexicographic ordering is well ordered.
  • We will see a generalization of induction to sets
    other than the integers in the next section.

14
Definitions
  • The principle of mathematical induction the
    statement ?n P(n), is true if P(1) is true and ?k
    (P(k) ? P(k 1)) is true.
  • Basis step the proof of P(1) in a proof by
    mathematical induction of ?n P(n).
  • Inductive step the proof of P(k) ? P(k 1) for
    all positive integers k in a proof by
    mathematical induction of ?n P(n).
  • Strong induction the statement ?n P(n) is true
    if P(1) is true and ?k (P(1) ? P(2) ? ? P(k))
    ? P(k 1) .
  • Well-ordering property every nonempty set of
    nonnegative integers has a least element.

15
Recursively Defined Functions
  • Definition A recursive or inductive
    definition of a function consists of two steps.
  • BASIS STEP Specify the value of the function at
    zero.
  • RECURSIVE STEP Give a rule for finding its value
    at an integer from its values at smaller
    integers.
  • A function f(n) is the same as a sequence a0,
    a1, , where ai, where f(i) ai.

16
Recursively Defined Functions
  • Example
  • Suppose f is defined by
  • f(0) 3,
  • f(n 1) 2f(n) 3
  • Find f(1), f(2), f(3), f(4)
  • Solution
  • f(1) 2f(0) 3 23 3 9
  • f(2) 2f(1) 3 29 3 21
  • f(3) 2f(2) 3 221 3 45
  • f(4) 2f(3) 3 245 3 93

17
Recursively Defined Functions
  • Example
  • Give a recursive definition of the factorial
    function n!
  • Solution
  • f(0) 1
  • f(n 1) (n 1) f(n)

18
Recursively Defined Functions
  • Example
  • Give a recursive definition of
  • Solution
  • The first part of the definition is
  • The second part is

19
Recursively Defined Sets and Structures
  • Recursive definitions of sets have two parts
  • The basis step specifies an initial collection of
    elements.
  • The recursive step gives the rules for forming
    new elements in the set from those already known
    to be in the set.
  • Sometimes the recursive definition has an
    exclusion rule, which specifies that the set
    contains nothing other than those elements
    specified in the basis step and generated by
    applications of the rules in the recursive step.
  • We will always assume that the exclusion rule
    holds, even if it is not explicitly mentioned.
  • We will later develop a form of induction, called
    structural induction, to prove results about
    recursively defined sets.

20
Structural Induction and Binary Trees
  • Theorem
  • If T is a full binary tree, then n(T)
    2h(T)1 1.
  • Proof
  • Use structural induction.
  • BASIS STEP The result holds for a full binary
    tree consisting only of a root, n(T) 1 and h(T)
    0. Hence, n(T) 1 201 1 1.
  • RECURSIVE STEP Assume n(T1) 2h(T1)1 1 and
    also n(T2) 2h(T2)1 1 whenever T1 and T2 are
    full binary trees.
  • n(T) 1 n(T1) n(T2)
    (by recursive formula of n(T))
  • 1 (2h(T1)1 1) (2h(T2)1 1)
    (by inductive hypothesis)
  • 2max(2h(T1)1, 2h(T2)1 ) 1
  • 22max(h(T1),h(T2))1 1
    (max(2x, 2y) 2max(x,y) )
  • 22h(t) 1
    (by recursive definition of h(T))
  • 2h(t)1 1

-2 .
21
Generalized Induction
  • Generalized induction is used to prove results
    about sets other than the integers that have the
    well-ordering property.
  • For example, consider an ordering on N ? N,
    ordered pairs of nonnegative integers.
  • Specify that (x1, y1) is less than or equal to
    (x2, y2) if either x1 lt x2, or x1 x2 and y1
    lty2 .
  • This is called the lexicographic ordering.
  • Strings are also commonly ordered by a
    lexicographic ordering.
  • The next example uses generalized induction to
    prove a result about ordered pairs from N ? N.

22
Generalized Induction
  • Example
  • Suppose that am,n is defined for (m,n)?N N
    by a0,0 0 and
  • Show that am,n m n(n 1)/2 is defined
    for all (m,n)?N N.
  • Solution
  • Use generalized induction.
  • BASIS STEP a0,0 0 0 (01)/2
  • INDUCTIVE STEP Assume that am?,n? m? n?(n?
    1)/2 whenever(m?,n?) is less than (m,n) in the
    lexicographic ordering of N N .
  • If n 0, by the inductive hypothesis we can
    conclude
  • am,n am-1,n 1 m - 1 n(n 1)/2
    1 m n(n 1)/2 .
  • If n gt 0, by the inductive hypothesis we can
    conclude
  • am,n am-1,n 1 m n(n - 1)/2
    n m n(n 1)/2 .

-2 .
23
Recursive Algorithms
  • Definition
  • An algorithm is called recursive if it solves a
    problem by reducing it to an instance of the same
    problem with smaller input.
  • For the algorithm to terminate, the instance of
    the problem must eventually be reduced to some
    initial case for which the solution is known.

24
Recursive Factorial Algorithm
  • Example
  • Give a recursive algorithm for computing n!,
    where n is a nonnegative integer.
  • Solution
  • Use the recursive definition of the factorial
    function.
  • procedure factorial(n nonnegative integer)
  • if n 0 then return 1
  • else return nfactorial(n - 1)
  • output is n!

25
Recursive Binary Search Algorithm
  • Example Construct a recursive version of a
    binary search algorithm.
  • Solution Assume we have a1,a2,, an, an
    increasing sequence of integers. Initially i is 1
    and j is n. We are searching for x.
  • procedure binary search(i, j, x integers, 1 i
    j n)
  • m ?(i j)/2?
  • if x am then
  • return m
  • else if (x lt am and i lt m) then
  • return binary search(i,m-1,x)
  • else if (x gt am and j gtm) then
  • return binary search(m1,j,x)
  • else return 0
  • output is location of x in a1, a2,,an if it
    appears, otherwise 0

26
Proving Recursive Algorithms Correct
  • Both mathematical and strong induction are
    useful techniques to show that recursive
    algorithms always produce the correct output.
  • Example Prove that the algorithm for computing
    the powers of real numbers is correct.
  • Solution Use mathematical induction on the
    exponent n.
  • BASIS STEP a0 1 for every nonzero real
    number a, and power(a,0) 1.
  • INDUCTIVE STEP The inductive hypothesis is
    that power(a,k) ak, for all a ?0. Assuming the
    inductive hypothesis, the algorithm correctly
    computes ak1,
  • Since power(a,k 1) a power (a, k)
  • a ak
    ak1 .

procedure power(a nonzero real number, n
nonnegative integer) if n 0 then return 1 else
return a power (a, n - 1) output is an
-2 .
27
Definitions
  • Recursive definition of a function a definition
    of a function that specifies an initial set of
    values and a rule for obtaining values of this
    function at integers from its values at smaller
    integers.
  • Recursive definition of a set a definition of a
    set that specifies an initial set of elements and
    a rule for obtaining other elements from those in
    the set.
  • Structural induction a technique for proving
    results about recursively defined sets.
  • Recursive algorithm an algorithm that proceeds
    by reducing a problem to the same problem with
    smaller input.
  • Merge sort a sorting algorithm that sorts a list
    by splitting it in two, sorting each of the two
    resulting lists, and merging the results into a
    sorted list.
  • Iteration a procedure based on the repeated use
    of operations in a loop.

28
Recursively Defined Functions
  • Example
  • Give a recursive definition of the factorial
    function n!
  • Solution
  • f(0) 1
  • f(n 1) (n 1) f(n)

29
Recursive Algorithms
  • Definition
  • An algorithm is called recursive if it solves a
    problem by reducing it to an instance of the same
    problem with smaller input.
  • For the algorithm to terminate, the instance of
    the problem must eventually be reduced to some
    initial case for which the solution is known.

30
Recursive Factorial Algorithm
  • Example
  • Give a recursive algorithm for computing n!,
    where n is a nonnegative integer.
  • Solution
  • Use the recursive definition of the factorial
    function.
  • procedure factorial(n nonnegative integer)
  • if n 0
  • then return 1
  • else
  • return nfactorial(n - 1)
  • output is n!

31
Recursive Binary Search Algorithm
  • Example Construct a recursive version of a
    binary search algorithm.
  • Solution Assume we have a1,a2,, an, an
    increasing sequence of integers. Initially i is 1
    and j is n. We are searching for x.
  • procedure binary search(i, j, x integers, 1 i
    j n)
  • m ?(i j)/2?
  • if x am then
  • return m
  • else if (x lt am and i lt m) then
  • return binary search(i,m-1,x)
  • else if (x gt am and j gtm) then
  • return binary search(m1,j,x)
  • else return 0
  • output is location of x in a1, a2,,an if it
    appears, otherwise 0

32
Proving Recursive Algorithms Correct
  • Both mathematical and strong induction are
    useful techniques to show that recursive
    algorithms always produce the correct output.
  • Example Prove that the algorithm for computing
    the powers of real numbers is correct.
  • Solution Use mathematical induction on the
    exponent n.
  • BASIS STEP a0 1 for every nonzero real
    number a, and power(a, 0) 1.
  • INDUCTIVE STEP The inductive hypothesis is
    that power(a,k) ak, for all a ? 0. Assuming the
    inductive hypothesis, the algorithm correctly
    computes ak1,
  • Since power(a, k 1) a power (a, k)
  • a ak
    ak1 .

procedure power(a nonzero real number, n
nonnegative integer) if n 0 then return 1 else
return a power (a, n - 1) output is an
-2 .
33
The Relationship between (mod m) and mod m
Notations
  • The use of mod in a b (mod m) and a mod m
    b are different.
  • a b (mod m) is a relation on the set of
    integers.
  • In a mod m b, the notation mod denotes a
    function.
  • The relationship between these notations is made
    clear in this theorem.
  • Theorem 3
  • Let a and b be integers, and let m be a positive
    integer.
  • Then a b (mod m) if and only if a mod m b
    mod m.

34
Base b Representations
  • We can use positive integer b greater than 1 as a
    base, because of this theorem
  • Theorem 1
  • Let b be a positive integer greater than 1.
  • Then if n is a positive integer, it can be
    expressed uniquely in the form
  • n akbk ak-1bk-1 . a1b
    a0
  • where k is a nonnegative integer, a0,a1,. ak
    are nonnegative integers less than b, and ak? 0.
  • The aj, j 0,,k are called the base-b digits
    of the representation.
  • The representation of n given in Theorem 1 is
    called the base b expansion of n and is denoted
    by (akak-1.a1a0)b.
  • We usually omit the subscript 10 for base 10
    expansions.

35
Binary Expansions
  • Most computers represent integers and do
    arithmetic with binary (base 2) expansions of
    integers. In these expansions, the only digits
    used are 0 and 1.
  • Example
  • What is the decimal expansion of the integer
    that has (101011111)2 as its binary expansion?
  • Solution
  • (1 0101 1111)2
  • 128 027 126 025 124 123
    122 121 120 351.

36
Binary Expansions
  • Example
  • What is the decimal expansion of the integer
    that has (11011)2 as its binary expansion?
  • Solution
  • (11011)2
  • 1 24 123 022 121 120 27.

37
Octal Expansions
  • The octal expansion (base 8) uses the digits
    0,1, 2, 3, 4, 5, 6, 7.
  • Example
  • What is the decimal expansion of the number with
    octal expansion (7016)8 ?
  • Solution
  • 783 082 181 680 3598

38
Octal Expansions
  • Example
  • What is the decimal expansion of the number
    with octal expansion (111)8 ?
  • Solution
  • 182 181 180 64 8 1 73

39
Hexadecimal Expansions
  • The hexadecimal expansion needs 16 digits, but
    our decimal system provides only 10.
  • So letters are used for the additional symbols.
  • The hexadecimal system uses the digits
    0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F.
  • The letters A through F represent the decimal
    numbers 10 through 15.
  • Example
  • What is the decimal expansion of the number with
    hexadecimal expansion (2AE0B)16 ?
  • Solution
  • 2164 10163 14162 0161 11160
    175627

40
Hexadecimal Expansions
  • Example
  • What is the decimal expansion of the number
    with hexadecimal expansion (1E5)16 ?
  • Solution
  • 1162 14161 5160 256 224 5 485

41
Base Conversion
  • To construct the base b expansion of an integer
    n
  • Divide n by b to obtain a quotient and remainder.
  • n bq0 a0 0 a0 b
  • The remainder, a0 , is the rightmost digit in the
    base b expansion of n. Next, divide q0 by b.
  • q0 bq1 a1 0 a1 b
  • The remainder, a1, is the second digit from the
    right in the base b expansion of n.
  • Continue by successively dividing the quotients
    by b, obtaining the additional base b digits as
    the remainder. The process terminates when the
    quotient is 0.

continued ?
42
Base Conversion
  • Example
  • Find the octal expansion of (12345)10
  • Solution
  • Successively dividing by 8 gives
  • 12345 8 1543 1
  • 1543 8 192 7
  • 192 8 24 0
  • 24 8 3 0
  • 3 8 0 3
  • The remainders are the digits from right to
    left yielding (30071)8.

43
Comparison of Hexadecimal, Octal, and Binary
Representations
Initial 0s are not shown
Each octal digit corresponds to a block of 3
binary digits. Each hexadecimal digit corresponds
to a block of 4 binary digits. So, conversion
between binary, octal, and hexadecimal is easy.
44
Conversion Between Binary, Octal, and Hexadecimal
Expansions
  • Example
  • Find the octal and hexadecimal expansions of
    (11 1110 1011 1100)2.
  • Solution
  • To convert to octal, we group the digits into
    blocks of three (011 111 010 111 100)2, adding
    initial 0s as needed. The blocks from left to
    right correspond to the digits 3, 7, 2, 7, and 4.
    Hence, the solution is (37274)8.
  • To convert to hexadecimal, we group the digits
    into blocks of four (0011 1110 1011 1100)2,
    adding initial 0s as needed.
  • The blocks from left to right correspond to the
    digits 3, E, B, and C. Hence, the solution is
    (3EBC)16.

45
Primes
  • Definition
  • A positive integer p greater than 1 is called
    prime if the only positive factors of p are 1 and
    p.
  • A positive integer that is greater than 1 and is
    not prime is called composite.
  • Example
  • The integer 7 is prime because its only positive
    factors are 1 and 7, but 9 is composite because
    it is divisible by 3.

46
The Fundamental Theorem of Arithmetic
  • Theorem
  • Every positive integer greater than 1 can be
    written uniquely as a prime or as the product of
    two or more primes where the prime factors are
    written in order of nondecreasing size.
  • Examples
  • 100 2 2 5 5 22 52
  • 641 641
  • 999 3 3 3 37 33 37
  • 1024 2 2 2 2 2 2 2 2 2 2
    210

47
Greatest Common Divisor
  • Definition
  • Let a and b be integers, not both zero.
  • The largest integer d such that d a and also d
    b is called the greatest common divisor of a
    and b.
  • The greatest common divisor of a and b is
    denoted by gcd(a, b).
  • One can find greatest common divisors of
    small numbers by inspection.
  • Example
  • What is the greatest common divisor of 24 and
    36?
  • Solution
  • gcd(24, 26) 12
  • Example
  • What is the greatest common divisor of 17 and
    22?
  • Solution
  • gcd(17, 22) 1

48
Greatest Common Divisor
  • Definition
  • The integers a and b are relatively prime if
    their greatest common divisor is 1.
  • Example
  • 17 and 22

49
Greatest Common Divisor
  • Definition
  • The integers a1, a2, , an are pairwise
    relatively prime if gcd(ai, aj) 1 whenever 1
    iltj n.
  • Example
  • Determine whether the integers 10, 17, and 21
    are pairwise relatively prime.
  • Solution
  • Because gcd(10, 17) 1, gcd(10, 21) 1, and
    gcd(17,21) 1, 10, 17, and 21 are pairwise
    relatively prime.

50
Greatest Common Divisor
  • Example
  • Determine whether the integers 10, 19, and 24
    are pairwise relatively prime.
  • Solution
  • Because gcd(10, 24) 2, 10, 19, and 24 are
    not pairwise relatively prime.

51
Least Common Multiple
  • Definition
  • The least common multiple of the positive
    integers a and b is the smallest positive
    integer that is divisible by both a and b.
  • It is denoted by lcm(a,b).
  • The least common multiple can also be computed
    from the prime factorizations.
  • This number is divided by both a and b and no
    smaller number is divided by a and b.
  • Example
  • lcm(233572, 2433) 2max(3,4) 3max(5,3)
    7max(2,0) 24 35 72
  • The greatest common divisor and the least
    common multiple of two integers are related by
  • Theorem 5
  • Let a and b be positive integers. Then ab
    gcd(a,b) lcm(a,b)
  • (proof is Exercise 31)

52
Euclidean Algorithm
Euclid (325 B.C.E. 265 B.C.E.)
  • The Euclidian algorithm is an efficient method
    for computing the greatest common divisor of two
    integers.
  • It is based on the idea that gcd(a,b) is equal
    to gcd(a,c) when a gt b and c is the remainder
    when a is divided by b.
  • Example Find gcd(91, 287)
  • 287 91 3 14
  • 91 14 6 7
  • 14 7 2 0
  • gcd(287, 91) gcd(91, 14) gcd(14, 7) 7

Divide 287 by 91
Divide 91 by 14
Divide 14 by 7
Stopping condition
continued ?
53
Euclidean Algorithm
  • The Euclidean algorithm expressed in pseudocode
    is
  • The time complexity of the algorithm is O(log b),
    where a gt b.
  • procedure gcd(a, b positive integers)
  • x a
  • y b
  • while y ? 0
  • r x mod y
  • x y
  • y r
  • return x gcd(a,b) is x

54
Cryptographic Protocols Key Exchange
  • Cryptographic protocols are exchanges of messages
    carried out by two or more parties to achieve a
    particular security goal.
  • Key exchange is a protocol by which two parties
    can exchange a secret key over an insecure
    channel without having any past shared secret
    information.

55
Product Rule
  • The Product Rule
  • A procedure can be broken down into a sequence
    of i tasks.
  • There are n1 ways to do the first task
  • and n2 ways to do the second task
  • and n ways to do the th task
  • and ni ways to do the ith task
  • Then there are n1 n2 ni ways to do the
    procedure.

56
The Product Rule
  • Example
  • How many different license plates can be made
    if each plate contains a sequence of three
    uppercase English letters followed by three
    digits?
  • Solution
  • By the product rule, there are 26 26 26
    10 10 10
  • n1 n2 n3 n4 n5 n6
  • 17,576,000 different possible license
    plates.

57
Basic Counting Principles The Sum Rule
  • The Sum Rule
  • If a task can be done either in one of n1 ways
    or in one of n2 ways to do the task, where none
    of the set of n1 ways is the same as any of the
    n2 ways, then there are n1 n2 ways to do the
    task.
  • Example
  • The mathematics department must choose either a
    student or a faculty member as a representative
    for a university committee.
  • How many choices are there for this
    representative if there are 37 members of the
    mathematics faculty and 83 mathematics majors and
    no one is both a faculty member and a student.
  • Solution
  • By the sum rule it follows that there are 37
    83 120 possible ways to pick a representative.

58
Counting Functions
  • Counting Functions
  • How many functions are there from a set with m
    elements to a set with n elements?
  • Questions to ask oneself
  • What is a function? One item from domain to
    one in codomain.
  • How many elements in domain in codomain?
  • For each item in the domain, how many choices
    can you make in the codomain?

59
Combining the Sum and Product Rule
  • Example
  • Suppose statement labels in a programming
    language can be either a single letter or a
    letter followed by a digit.
  • Find the number of possible labels.
  • Solution
  • Use the product rule.
  • 26 26 10 286

60
Counting Functions
  • Solution
  • Since a function represents a choice of one of
    the n elements of the codomain for each of the m
    elements in the domain, the product rule tells us
    that there are n n n nm such
    functions.
  • nm codomaindomain (function)

61
  • Each function is a unique choice from an element
    in m to an element in n.
  • But each choice in m may select the any
    element in n.

62
Choices

63
Other questions
  • Other questions to ask
  • Is it a combination?
  • what is a combination?
  • 2 types
  • combination of product and sum rules
  • combination of r permutations
  • Is it a permutation?
  • Is repetition allowed?
  • What is repetition?
  • Are the objects distinguishable?
  • Example the S in word SUCCESS. (combination
    of 4 permutations)
  • C(7,3)C(4,2)C(2,1)C(1,1) 420

64
Is it a combination?
  • Example
  • Suppose statement labels in a programming
    language can be either a single letter or a
    letter followed by a digit.
  • Find the number of possible labels.
  • Solution
  • Use the product rule.
  • 26 26 10 286

65
Is it a permutation?
  • A permutation of a set of distinct objects is an
    ordered arrangement of these objects.
  • Example Let S 1,2,3.
  • The ordered arrangement 3,1,2 is a permutation of
    S.
  • Example How many ways are there to select a
    first-prize winner, a second prize winner, and a
    third-prize winner from 100 different people who
    have entered a contest?
  • P(100,3) 100 99 98 970,200

66
r-permuation
  • An ordered arrangement of r elements of a set
    is called an r-permuation.
  • Example Let S 1,2,3.
  • The ordered arrangement 3, 2 is a 2-permutation
    of S.

67
A Formula for the Number of Permutations
  • The number of r-permuatations of a set with n
    elements is denoted by P(n,r).
  • What is n? The number of elements in a set.
  • What is r? The number of elements selected.

68
Combinations
  • An r-combination of elements of a set is an
    unordered selection of r elements from the set.
  • Thus, an r-combination is simply a subset of
    the set with r elements.
  • The number of r-combinations of a set with n
    distinct elements is denoted by C(n, r). (Also
    (n!/(n-r)!)
  • The notation is also used and is called a
    binomial coefficient.

69
Combinations
  • Example Let S be the set a, b, c, d.
  • Then a, c, d is a 3-combination from S.
  • It is the same as d, c, a since the order
    listed does not matter.
  • C(4,2) 6 because the 2-combinations of a, b,
    c, d are the six subsets a, b, a, c, a, d,
    b, c, b, d, and c, d.

70
Combinations
  • Example How many poker hands of five cards can
    be dealt from a standard deck of 52 cards?
  • Also, how many ways are there to select 47
    cards from a deck of 52 cards?
  • Solution Since the order in which the cards
    are dealt does not matter, the number of five
    card hands is
  • (n 52, r 5)

71
Combinations
  • C(n, r) C(n, n - r)

72
Permutations with Repetition
  • The number of r-permutations of a set of n
    objects with repetition allowed is nr.
  • Example How many strings of length r can be
    formed from the uppercase letters of the English
    alphabet?
  • Solution The number of such strings is 26r,
    which is the number of r-permutations of a set
    with 26 elements.

73
Combinations with Repetition
  • Choice
  • Example How many ways are there to select five
    bills from a box containing at least five of
    each of the following denominations 1, 2, 5,
    10, 20, 50, and 100? (7 ways)
  • n choices 7 (the demominations) are
    indistinguishable!
  • r ways 5 (how many bills).
  • (must have enough bills to allow choice of any
    5)

74
Indistinguishable Object Combinations
  • C(n r 1,r) C(n r 1, n 1)
  • C(ways choices - 1, ways)
  • C(7 5 1, 5) C(7 5 1, 7 1)
  • C(11, 5) C(11, 6)
  • 11!/(11-5)!5!
  • 11!/6!5!

75
Indistinguishable Object Combinations
  • Example Suppose that a cookie shop has four
    different kinds of cookies. How many different
    ways can six cookies be chosen?
  • Solution The number of ways to choose six
    cookies is the number of 6-combinations of a set
    with four elements.
  • C(n r 1, r) C(6 4 -1, 4) C(9, 4)
  • 9!/4!5!
  • is the number of ways to choose six cookies
    from the four kinds.
  • Incorrect
Write a Comment
User Comments (0)
About PowerShow.com