Counting - PowerPoint PPT Presentation

1 / 11
About This Presentation
Title:

Counting

Description:

Situations where counting techniques are used ... Notation: For any finite set A, n(A) denotes the number of elements in A. Then ... – PowerPoint PPT presentation

Number of Views:66
Avg rating:3.0/5.0
Slides: 12
Provided by: vard
Category:
Tags: counting | seta

less

Transcript and Presenter's Notes

Title: Counting


1
Counting
2
Situations where counting techniques are used
  • You toss a pair of dice in a casino game.
  • You win if the numbers showing face up have
    a sum of 7.
  • Question What are your chances of winning
    the game?

3
Situations where counting techniques are used
  • To satisfy a certain degree requirement, you are
    supposed to take 3 courses from the following
    group of courses
  • CS300, CS301, CS302, CS304,
  • CS305, CS306, CS307, CS308.
  • Question In how many different ways the
    requirement can be satisfied?

4
Situations where counting techniques are used
  • There are 4 jobs that should be processed
  • on the same machine.
  • (Cant be processed simultaneously).
  • Here is an example of a possible schedule
  • Question What is the number of all possible
    schedules?

5
Situations where counting techniques are used
  • Consider the following nested loop
  • for i1 to 5
  • for j1 to 6
  • Statement 1
  • Statement 2 .
  • next j
  • next i
  • Question How many times the statements in the
    inner loop will be executed?

6
Counting and Probability
  • Suppose we toss two coins.
  • Question. What are the chances of getting 0, 1, 2
    heads?
  • The set of all possible outcomes
  • S (H,H), (H,T), (T,H), (T,T)
  • Event of getting exactly one head
    corresponds to the subset (H,T), (T,H) .
  • Thus, chances of getting exactly one head is 2
    / 4 .5 ( which is the same as 50 ).

7
Random Processes, Sample Space and Events
  • A process is called random if
  • ? a set of different outcomes are possible
  • ? one of the outcomes is sure to occur
  • ? but it is impossible to predict with certainty
  • which outcome that will be.
  • A sample space is the set of all possible
    outcomes
  • of a random process or experiment.
  • An event is a subset of a sample space.

8
Probability
  • If S is a finite sample space
  • (in which all outcomes are equally likely),
  • E is an event in S,
  • then the probability of E is
  • Notation For any finite set A,
  • n(A) denotes the number of elements in A.
  • Then

9
Example on Probability
  • You toss a pair of dice in a casino game.
  • You win if the numbers showing face up
  • have a sum of 7.
  • Question What are your chances of
    winning the game?
  • Solution.
  • Sample Space S (1,1), (1,2), , (6,6)
  • (i,j) ? i, j ?1,,6
  • The event that the sum is 7
  • E (i,j) i, j ?1,,6 and ij7
  • (1,6), (2,5), (3,4), (4,3), (5,2), (6,1)
  • n(S) 62 36 , n(E) 6.
  • Thus, chances of winning P(E) 6/36 1/6 .

10
Number of Elements in a List
  • If m and n are integers and m n ,
  • then there are n-m1 integers
  • from m to n inclusive.
  • Example
  • a) How many elements are there in the array
    A12, A13, , A75, A76 ?
  • b) What is the probability
  • that a randomly chosen element of the array
    has a subscript which is divisible by 7 ?

11
Number of Elements in a List
  • Example (cont.)
  • Solution a) 76 12 1 65 .
  • b) Sample space
  • S Ai 12 i 76 .
  • Event that the index is divisible by 7
  • E Ai 12 i 76 and 7i .
  • n(S) 65 from part (a).
  • 1472, 2173, , 70710 .
  • Thus, n(E) 10-21 9 .
  • Hence the probability that the index is
    divisible by 7
  • P(E) n(E) / n(S) 9 / 65 .14
Write a Comment
User Comments (0)
About PowerShow.com