CSCE 222 Lecture 19

From Notes
Jump to navigation Jump to search

« previous | Wednesday, March 9, 2011 | next »


Counting

Lecture Notes


Product Rule

Suppose a procedure can be broken into two tasks:

  • there are ways to do the first task, and
  • for each of these ways, there are ways to do the second task.

Therefore, the total number of possible tasks is


Number of Possible Functions

Suppose that is a function from a set with elements to with elements. How many possible functions exist?


Sum Rule

is union of 2 non-overlapping finite sets and :


Example

Each user has a password 6-8 characters long, where each character is an uppercase letter or a digit. Each password must contain at least one digit. How many possible passwords are there?

Let be number of passwords, is the number of passwords with length Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle k} , hence Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle P=P_6+P_7+P_8} .

Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle P_k = 36^k-26^k} : number of strings of length Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle k} with digits or uppercase letters − number of strings that contain only letters.

Therefore, Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle P = 36^6-26^6+36^7-26^7+36^8-26^8}

Inclusion/Exclusion

Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle |A \cup B| = |A| + |B| - |A \cap B|}

How many bit strings of length 8 either start with 1 or end with 00?

Let be the set of bit strings of length 8 that start with 1. Then

Let be the set of strings of length 8 that end with 00. Then

, the number of strings that start with 1 and end in 00.

Therefore,


Pigeonhole Principle

If is a positive integer and or more objects are placed into boxes, then there is at least one box containing two or more objects.

Example: Among 367 people, there must be at least two people who share the same birthday. Max of 366 days in a (leap) year.


Example: For every positive integer , there is a multiple of that contains only the numbers 0 and 1.

Proof: Consider the integers . Dividing each by yields at most possible remainders. Since we have numbers, two must share the same remainder... What does this mean?


Sequences

A set of numbers.

subsequence
a sequence formed by removing some elements of a larger sequence while maintaining a certain order.
strictly increasing
for all numbers in a sequence, the next number is larger than all before it.
strictly decreasing
for all numbers in a sequence, the next number is smaller than all before it.

Example

Proof. Seeking a contradiction, we assume that there exists a sequence that does not contain any strictly increasing (or decreasing) subsequence of length n+1 or longer.

Let be the length of the longest increasing subsequence starting at . Let be the length of the longest decreasing subsequence starting at .

Notice that 1 ≤ , so there are distinct ordered pairs

Since all elements of the sequence are distinct real numbers, we either have or , where and are two elements in our sequence.


Permutations

A permutation of a set of distinct elements is an ordered arrangement of these objects:

If we decide to rearrange Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle r} elements in Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle S} , then it is called an Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle r} -permutation.

Let Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle P(n,r)} denote the number of Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle r} -permutations of a set containing Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle n} elements.

Simple Example

Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle \begin{align} P(\{1,2,3\}, 2) &= |\{\{1,2\}, \{1,3\}, \{2,1\}, \{2,3\}, \{3,1\}, \{3,2\}|\\ &= 3\ \mbox{ways to choose first element} \times 2\ \mbox{ways to choose the second element} \\ &= 6\ \mbox{by product rule} \end{align}}


In General

Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle \begin{align} P(n,r) &= n(n-1)(n-2) \ldots (n-r+1) \\ &= \frac{n!}{(n-r)!} \end{align}}

Complicated example

How many permutations of the letters A-H are there containing the string "ABC"?

Think of the phrase ABC as a single token. The other five positions can be filled with D-H. Therefore, 6!

Note: Look up lex