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 , hence .

: number of strings of length with digits or uppercase letters − number of strings that contain only letters.

Therefore,

Inclusion/Exclusion

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 elements in , then it is called an -permutation.

Let denote the number of -permutations of a set containing elements.

Simple Example


In General

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