Counting Technique: rcombinations with repetition allowed - PowerPoint PPT Presentation

1 / 8
About This Presentation
Title:

Counting Technique: rcombinations with repetition allowed

Description:

Definition: r-combinations with repetition allowed. from a set X of n elements ... We discussed four different ways. of choosing r elements from n . The summary ... – PowerPoint PPT presentation

Number of Views:86
Avg rating:3.0/5.0
Slides: 9
Provided by: vard
Category:

less

Transcript and Presenter's Notes

Title: Counting Technique: rcombinations with repetition allowed


1
Counting Techniquer-combinations with
repetition allowed
2
Number of iterations of a nested loop(First
Situation)
  • Consider the following nested loop
  • for i1 to n
  • for j1 to i-1
  • for k1 to j-1
  • Statements
  • next k
  • next j
  • next i
  • Question How many times the statements in the
    innermost loop will be executed?
  • Solution Each iteration corresponds to
  • a triple of integers (i, j, k) where i gt j gt
    k .
  • The set of all this kind of triples corresponds
    to
  • all 3-combinations of 1, , n .
  • Thus, the total number of iterations is C(n,3)
    .

3
Number of iterations of a nested loop(Second
Situation)
  • Consider the following nested loop
  • for i1 to n
  • for j1 to i
  • for k1 to j
  • Statements
  • next k
  • next j
  • next i
  • Question How many times the statements in the
    innermost loop will be executed?
  • Solution Each iteration corresponds to
  • a triple of integers (i, j, k) where i j
    k .
  • Examples (5, 3, 2), (4, 4, 3), (2, 1, 1), (3,
    3, 3) .
  • How to count the number of this kind of
    triples?

4
Number of iterations of a nested loop(Second
Situation)
  • Each triple corresponds to a string of crosses
    and vertical bars.
  • Numbers 1, 2, , n are considered as categories
  • n-1 vertical bars separate the categories
  • 3 crosses indicate
  • how many items from each category are chosen.
  • Examples when n5

5
Number of iterations of a nested loop(Second
Situation)
  • Each triple corresponds to
  • a string of n-1 vertical bars and 3 crosses.
  • The length of any string is (n-1)3 n2 .
  • The number of distinct positions
  • for the 3 crosses in a string is C(n2, 3) .
  • Thus, the number of distinct triples is C(n2,
    3) .
  • Generalizing,
  • if the number of nested loops is r
  • then the number of iterations is C(n-1r, r) .

6
r-combinations with repetition allowed
  • Definition
  • r-combinations with repetition allowed
  • from a set X of n elements
  • is an unordered selection of r elements
    taken from X with repetition allowed.
  • The number of r-combinations with repetition
    allowed from a set of n elements is C(n-1r, r) .

7
Which formula to use?
  • We discussed four different ways
  • of choosing r elements from n .
  • The summary of formulas
  • used in the four situations

8
Useful formulas for special cases
  • C(n,n-r) C(n,r) .
  • Proof
  • C(n,n)1
  • C(n,n-1) C(n,1) n
  • C(n,n-2) C(n,2) n(n-1) / 2
Write a Comment
User Comments (0)
About PowerShow.com