Beruflich Dokumente
Kultur Dokumente
Discrete mathematics is the branch of mathematics dealing with objects that can assume only distinct,
separated values. The term "discrete mathematics" is therefore used in contrast with "continuous mathematics,"
which is the branch of mathematics dealing with objects that can vary smoothly (and which includes, for
example, calculus). Whereas discrete objects can often be characterized by integers, continuous objects require real
numbers. The study of how discrete objects combine with one another and the probabilities of various outcomes is
known as combinatorics. Other fields of mathematics that are considered to be part of discrete mathematics
include graph theory and the theory of computation. Topics in number theory such as congruencies and recurrence
relations are also considered part of discrete mathematics. The study of topics in discrete mathematics usually
includes the study of algorithms, their implementations, and efficiencies. Discrete mathematics is the mathematical
language of computer science, and as such, its importance has increased dramatically in recent decades.
Discrete math is essential to college-level mathematics and beyond. Discrete math together with calculus
and abstract algebra is one of the core components of mathematics at the undergraduate level. Students who learn
a significant quantity of discrete math before entering college will be at a significant advantage when taking
undergraduate-level math courses.
Discrete math is the mathematics of computing. The mathematics of modern computer science is built almost
entirely on discrete math, in particular combinatorics and graph theory. This means that in order to learn the
fundamental algorithms used by computer programmers, students will need a solid background in these subjects.
Indeed, at most universities, a undergraduate-level course in discrete mathematics is a required part of pursuing a
computer science/engineering degree.
Discrete math is very much "real world" mathematics. Many students' complaints about traditional math
algebra, geometry, trigonometry, and the likeis "What is this good for?" The somewhat abstract nature of these
subjects often turn off students. By contrast, discrete math, in particular counting and probability, allows students
to very quickly explore non-trivial "real world" problems that are challenging and interesting.
Discrete math teaches mathematical reasoning and proof techniques. Algebra is often taught as a series of
formulas and algorithms for students to memorize (for example, the quadratic formula, solving systems of linear
equations by substitution, etc.), and geometry is often taught as a series of "definition-theorem-proof" exercises
that are often done by rote (for example, the infamous "two-column proof"). While undoubtedly the subject matter
being taught is important, the material (as least at the introductory level) does not lend itself to a great deal of
creative mathematical thinking. By contrast, with discrete mathematics, students will be thinking flexibly and
creatively right out of the box. There are relatively few formulas to memorize; rather, there are a number of
fundamental concepts to be mastered and applied in many different ways.
Discrete math is fun. Many students, especially bright and motivated students, find algebra, geometry, and even
calculus dull and uninspiring. Rarely is this the case with most discrete math topics. When we ask students what the
favorite topic is, most respond either "combinatorics" or "number theory." Simply put, most students find discrete
math more fun than algebra or geometry.
PROPOSITIONAL LOGIC
A proposition is a declarative statement thats either TRUE or FALSE (but not both).
Propositions Not Propositions
3 + 2 = 32 Bring me coffee!
CS173 is Bryans favorite class. CS173 is her favorite class.
Every cow has 4 legs. 3+2
There is other life in the universe. Do you like Cake?
To answer, we need the notion of logical equivalence. p is logically equivalent to q if their truth tables are the
same.
We write p q.
p q pq p q p q p
Challenge: Try to find a proposition that is T T F T
T q T T
p
equivalent
T to rp Fq,q but
r thatp uses
(q r) only the
F
pq T F pr F (p q) (p Fr)
T T T T T T F T T T
connectives
F , , and T. T T T
T T F F T T F F T T T T
T F F T F F TT T T T
T F F F T T T T
F T T T T T T T
PROPOSITIONAL
F T F LOGICF PROOF FOF 1 FAMOUS T F F
F F T F F F T F
Distributive:
F F F
p (q F r) (p q)F (p r) F F F
PROPOSITIONAL EQUIVALENCES
TAUTOLOGIES, CONTRADICTIONS, CONTINGENCIES
DEF: A compound proposition is called a tautology if no matter what truth values its atomic propositions have, its
own truth value is T.
EG: p p
On the other hand, a compound propositions whose truth value isnt constant is called a contingency.
p q p p q p (p q ) [p (p q )]q
T T F T F T
T F F T F T
F T T T T T
F F T F F T
EG:
while(x <= 3 || x > 3) if(x > y)
x++; if(x == y)
return never got here;
LOGICAL EQUIVALENCES
DEF: Two compound propositions p, q are logically equivalent if their biconditional joining p q is a tautology.
Logical equivalence is denoted by p q.
EG: The contrapositive of a logical implication is the reversal of the implication, while negating both components.
I.e. the contrapositive of p q is q p . As well see next: p q q p
p q p q q p (p q) (q p)
T T T T T
T F F T F
F T T F F
F F T T T
Q1: How many rows are required to construct the truth-table of: ( (q(pr)) ((sr)t)) (qr )?
Q2: How many rows are required to construct the truth-table of a proposition involving n atomic components?
A1: 32 rows, each additional variable doubles the number of rows
A2: In general, 2n rows.
Therefore, as compound propositions grow in complexity, truth tables become more and more unwieldy. Checking
for tautologies/logical equivalences of complex propositions can become a chore, especially if the problem is
obvious.
- Like adding 0
- Like multiplying by 0
- Delete redundancies
- I dont like you, not
- Like x+y = y+x
- Like (x+y)+z = y+(x+z)
- Like (x+y)z = xz+yz
- Excluded middle
- Negating creates opposite
- Definition of implication in terms of Not and Or
DEMORGAN IDENTITIES
DeMorgans identities allow for simplification of negations of complex expressions
Conjunctional negation:
(p1p2pn) (p1p2pn) Its not the case that all are true iff one is false.
Disjunctional negation:
(p1p2pn) (p1p2pn) Its not the case that one is true iff all are false.
[p (p q )]q
[(p p)(p q)]q Distributive
[ F (p q)]q ULE
[p q ]q Identity
[p q ] q ULE
[(p) q ] q DeMorgan
[p q ] q Double Negation
p [q q ] Associative
p [q q ] Commutative
pT ULE
T Domination
PREDICATE LOGIC
A proposition in the form 5 is an integer may be viewed as having two components. One is an object or individual
and the other is a property which that object or individual is said to possess. We refer to the property as a
predicate. We denote objects and individuals using lower case letters-usually first letter of the name of that object
or individual.
These are not propositions since they cannot be declared true or false. They are called propositional functions.
Examples:
Suppose that predicates and individuals are defined as follows.
S: should be shunned M: is a friend of mine.
U: prone to unruly behavior. d: Danielle.
J: is a friend of Josh. e: Erika.
Solutions:
i. J(d) M(e) iv. ( J(d) U(d) ) S(d)
ii. x ( J(x) U(x) ) v. x ( M(x) J(x) ) x ( J(x) U(x) )
iii. x ( J(x) M(x) )
EXERCISES
EXERCISE 2.1
1. Let P(x) denote the statement x 10. What are the truth values?
a. P(9) d. P(10)
b. P(12) e. P(0)
c. P(-10)
2. Let Q(x) denote the statement x is an integer. What are the truth values?
a. Q(-1) d. Q(-4)
b. Q(0) e. Q(4 )
c. Q(8 / 2)
3. Let P(x,y) denote the statement xy 15. What are the truth values?
a. P(5,3) d. P(-3,-6)
b. P(-3,5) e. P(2,7)
c. P(-3,-5)
EXERCISE 2.2
1. Let P(x) be the statement x spends more than four hours surfing the internet, where the domain for x
consists of all students. Write a statement in English corresponding to the for
a. xP(x) d. xP(x)
b. x P(x) e. xP(x)
c. xP(x)
2. Let Q(x) be the statement x has developed a program in JAVA, where the domain for consists of the
students in ICS. Express each of these quantifications in English.
a. xQ(x) d. xQ(x)
b. x Q(x) e. x Q(x)
c. xQ(x)
EXERCISE 2.3
Let P(x) be the statement x is an integer and Q(x) be a statement x is a rational number, where the domain is
the set of real numbers. Express each of these quantifications in English.
a. P(6) f. xP(x)
b. P(1/2) g. xP(x)
c. Q(0) h. x Q(x)
d. Q(2/3) i. x ( P(x) Q(x) )
e. Q(2 ) j. x ( Q(x) P(x) )
EXERCISE 2.4
1. Let P(x) be the statement x is a positive integer and Q(x) be a statement x is a rational number, where
the domain is the set of all numbers. Express each of these quantifications in English.
a. xP(x) f. xP(x)
b. xP(x) g. xP(x)
c. xQ(x) h. x Q(x)
d. xQ(x) i. x ( P(x) Q(x) )
e. xP(x) j. x ( Q(x) P(x) )
EXERCISE 2.5
Symbolize the following by using quantifiers, predicates and logical connectives.
1. All rational numbers are real numbers.
2. Some rational numbers are integers.
3. Some even numbers are multiple of two, four and five.
4. Some triangles are scalene.
5. Every integer is multiple of 10 if and only if it is a multiple of 5 and 2.
6. Some prime integers are odd integers.
7. Everyone is charitable and compassionate.
8. Some are committee and competent in doing their job.
9. Everyone who studies logic is good in reasoning.
10. Some students are good in mathematics and physics.
EXERCISE 2.6
1. What is the truth value of the quantification xP(x), where the domain of discourse is the set of integers?
c. P(x): x+3 4
2. What is the truth value of the quantification xP(x), where the domain of discourse is the set of integers?
a. P(x): 2x-1 x+1 d. P(x): 5x-3 = 2x
c. P(x): x2 +1 = 0
2
d. P(x): x=1
3
UNIVERSE OF DISCOURSE
Given a propositional function P(x), the universe of discourse for the variable x is defined to be the set from which
we may select an object or individual to substitute for x.
Examples:
1. The proposition No integer is a rational number, i.e. xP(x). The negation of All integers are rational
numbers is There is at least integer that is not a rational number. Hence the proposition which is
equivalent to xP(x) is xP(x).
2. The negation of the existentially quantified proposition Some integers are rational is the proposition that
it is not the case that some integers are rational numbers. i.e. No integer is a rational number. To
paraphrase this For every x in the universe, x is not a rational number and symbolizes it xP(x). Hence
xP(x) is equivalent to xP(x).
TWO-PLACE PREDICATES
Two-place predicates referred to as relational phrases, they express a relation between two components. We can
form propositional function from two-place predicates.
Examples:
is greater than, is taller than, is bigger than, is less than, If Y denotes is younger than. Y(a,b) denotes the
propositional function a is younger than b. Let j denote John. Y(j,b) the expression denotes John is younger than
b.
Two-variable propositional functions can be quantified. xY(x,y) denotes Everyone is younger than y. If we
substitute j for y, we obtain the proposition Everyone is younger than John denoted by xY(x,j).
NESTED QUANTIFIERS
Use of two quantifiers, xyY(x,y), may be read as For all x and for all y, x is younger y or Everyone is younger
than everyone. This is a proposition since it clearly has a truth value false.
Examples:
There are eight propositions which can be formed by quantifying a two variable propositional function. For the
propositional function Lxy x likes y and the universe of people:
1. xyL(x,y) 5. xyL(x,y)
2. yxL(x,y) 6. yxL(x,y)
3. xyL(x,y) 7. xyL(x,y)
4. yxL(x,y) 8. yxL(x,y)
Many mathematical statements involve multiple quantifications of propositional functions involving more than one
variable.
Examples:
1. Let P(x,y) be the statement x*y = y*x , where the domain for all variable consists of all real numbers.
The quantification, xyP(x,y) denotes the proposition For all real number x, for all real number y, x*y =
y*x. Also, The quantification, yxP(x,y) denotes the proposition, For all real number y, for all real
number x, x*y = y*x.
2. Let F(x,y) denote x*y = 1 , where the domain for all variable consists of all real numbers. The
quantification, xyP(x,y) denotes the proposition, For all real number x there is a real number y such that
x*y =1.
3. Let P(x,y) be the statement x*(y*z) = (x*y)*z , where the domain for all variable consists of all real
numbers. The quantification, xyzP(x,y,z) denotes the proposition , For all real number x, for all real
number y, for all real number z, x*(y*z) = (x*y)*z
4. Translating the quantified statement xy( (x0)(y0)(xy0) ), where the domain fr all variables consists
of all real numbers. This will read: For all real number x, for all real number y, if x is a positive real number
and y is a negative real number then their product is a negative real number or putting it plainly, The
product of a positive and a negative real numbers is a negative real number.
Solution:
1. Benjie is ferocious cat that belongs to Charlene.
2. Anne detest all cats.
3. Some ferocious cat belongs to Charlene.
4. All ferocious cats are detested by everyone.
5. All ferocious cats are detested by someone.
EXERCISE 2.7
1. Let P(x,y) denote the sentence 2x+y=5. What are the truth values of the following where the domain of x
and y is set of all integers?
a. xyP(x,y) c. xyP(x,y)
b. xyP(x,y) d. xyP(x,y)
2. Let P(x,y) denote the sentence x 2+1 x+1 . What are the truth values of the following where the
EXERCISE 2.8
Let P(x,y) be the statement student x has taken y, where the domain for x consists of all computer science
students of ICS and for y consists of all mathematical courses. Express each of these quantifications in English.
a. xyP(x,y) e. xyP(x,y)
b. yxP(x,y) f. yxP(x,y)
c. xyP(x,y) g. xyP(x,y)
d. yxP(x,y) h. yxP(x,y)
EXERCISE 2.9
Let P(x,y) be the statement student x has written a program in y, where the domain for x consists of all computer
science students of ICS and for y consists of all programming languages. Express each of these quantifications in
English.
a. xyP(x,y) e. xyP(x,y)
b. yxP(x,y) f. yxP(x,y)
c. xyP(x,y) g. xyP(x,y)
d. yxP(x,y) h. yxP(x,y)
SETS
DEFINING SETS
Definition: A set is an unordered collection of objects.
The objects in a set are called the elements or members of the set S, and we say S contains its elements.
After we define a set, the set is a single mathematical object, and it can be an element of another set.
e.g. S = {{1,2}, {1,3}, {1,4}, {2,3}, {2,4}, {3,4}}
by a set by describing the properties that its elements should satisfy. We use the notation: to { x A| P( x)}
define the set as the set of elements, x, in A such that x satisfies property P.
e.g. {x | x is a real number and -2 < x < 5}
{x | x is a prime number and x < 1000}
Examples of Sets
Well known sets:
the set of all real numbers, R
the set of all complex numbers, C
Other examples:
The set of all polynomials with degree at most three: {1, x, x 2, x3, 2x+3x2,}.
The set of all n-bit strings: {0000, 0001, , 1111}
MEMBERSHIP
Order, number of occurence are not important.
e.g. {a,b,c} = {c,b,a} = {a,a,b,c,b}
SIZE OF A SET
In this course we mostly focus on finite sets.
Definition: The size of a set S, denoted by |S|, is defined as the number of elements contained in S.
Later we will study how to determine the size of the following sets:
the set of poker hands which are full house.
the set of n-bit strings without three consecutive ones.
the set of valid ways to add n pairs of parentheses
SUBSET
Definition: Given two sets A and B, we say A is a subset of B, denoted by A B , if every element of A is also
an element of B.
If A = {4, 8, 12, 16} and B = {2, 4, 6, 8, 10, 12, 14, 16}, then by A B
but by BA
AA because every element in A is an element of A.
If A is the set of prime numbers and B is the set of odd numbers, then A B
EXERCISES
1. Z R ?
2. {3} {5,7,3}?
3. every set?
7. If A B and B C, then A C?
intersection: A B={ x U| x Ax B
Definition: Two sets are said to be disjoint if their intersection is an empty set.
e.g. Let A be the set of odd numbers, and B be the set of even numbers. Then A and B are disjoint.
union: A B={ x U| x Ax B
difference: AB={ x U| x Ax B
Fact: | AB|=| A| A B
complement:
A c ={ x U| x A }
A=
e.g. Let U = Z and A be the set of odd numbers.
Then A is the set of even numbers.
Fact: If A B , then B A
Examples
A = {1, 3, 6, 8, 10} B = {2, 4, 6, 7, 10}
A B = {6, 10}, A B = {1, 2, 3, 4, 6, 7, 8, 10} A-B = {1, 3, 8}
A B = {x U | x is divisible by 15}
PARTITIONS OF SETS
Two sets are disjoint if their intersection is empty.
A collection of nonempty sets {A 1, A2, , An} is a partition of a set A if and only if A= A 1 A 2 An A1, A2,
e.g. Let A be the set of integers divisible by 6. A 1 be the set of integers divisible by 2. A 2 be the set of integers
divisible by 3. Then {A1, A2} is not a partition of A, because A1 and A2 are not disjoint, and also A A 1
A 2 (so
both conditions are not satisfied).
POWER SETS
power set: pow ( A ) { S|S A }
In words, the power set pow(A) of a set A contains all the subsets of A as members.
pow({a,b,c,d}) = { , {a}, {b}, {c}, {d}, {a,b}, {a,c}, {b,c}, {a,d}, {b,d}, {c,d}, {a,b,c}, {a,b,d}, {a,c,d},
{b,c,d}, {a,b,c,d}}
CARTESIAN PRODUCTS
Definition: Given two sets A and B, the Cartesian product A x B is the set of all ordered pairs (a,b), where a is in
e.g. Let A be the set of letters, i.e. {a,b,c,,x,y,z}. Let B be the set of digits, i.e. {0,1,,9}. A x A is just the set of
strings with two letters. B x B is just the set of strings with two digits. A x B is the set of strings where the first
character is a letter and the second character is a digit.
Using the above examples, A x A x A is the set of strings with three letters. Our ID card number has one letter and
then six digits, so the set of ID card numbers is the set A x B x B x B x B x B x B.
Fact: If |A| = n and |B| = m, then |A x B| = mn.
Fact: If |A| = n and |B| = m and |C| = l, then |A x B x C| = mnl.
Fact: |A1 x A2 x x Ak| = |A1| x |A2| x x |Ak|.
Exercises
1. Let A be the set of prime numbers, and let B be the set of even numbers. What is A B and |A
B|?
2. Is |A B| > |A| > |A B| always true?
3. Let A be the set of all n-bit binary strings, A i be the set of all n-bit strings with i ones. Is (A 1, A2, , Ai, ,
An) a partition of A?
4. Why the name Cartesian product?
5. Let A = {x, y}. What is pow(A) x pow(A) and |pow(A) x pow(A)|?
SET IDENTITIES
Some basic properties of sets, which are true for all sets.
A B A
A A C
If A BB C , then A C
A A=
A
A=
A B=( AB) ( B A) ( A B)
Distributive Law:
1 A ( B C )=(A B)( A C) (1)
(2)
2 A ( B C )=( A B)( A C)
L.H.S
A=S 1 S 2 S 4 S 5
B C=S 4 S6
A (B C )=S1 S2 S 4 S5 S 6
R.H.S.
( A B)=S1 S 2 S 3 S4 S 5 S6
( A C )=S1 S2 S 4 S5 S 6 S7
( A B ) ( A C)=S 1 S 2 S4 S 5 S6
De Morgans Law:
A B= A B
A B= B
A
DISPROOF
( AB ) ( BC ) =AC ?
A B A B
1 2 3
2 3
1 C
C
4 5 6
5 6
4 7
7
L.H.S R.H.S
We can easily construct a counterexample to the equality, by putting a number in each region in the figure. Let A
= {1,2,4,5}, B = {2,3,5,6}, C = {4,5,6,7}. Then we see that L.H.S = {1,2,3,4} and R.H.S = {1,2}.
ALGEBRAIC PROOF
Sometimes when we know some rules, we can use them to prove new rules without drawing figures.
(A B)=A
B
e.g. we can prove without drawing figures.
(A B)=
A B
by using DeMorgans rule on A and B
A B
( B ) C
?
( ( A C ) B C )) =( A
(
( ( A C ) B C ))
( A (B C)
C) by DeMorgans law on the first half
C)
( A ( B C)
by DeMorgans law on the second half
B)
( A C
by Distributive law
B)
( A C
Exercises
A ( A B ) =AB ?
( A B)C=( AC )(BC)?
C)= A
( A B B
C
?
RUSSELLS PARADOX
Let W
={S SetsS S }
In words, W is the set that contains all the sets that dont contain themselves.
Is W in W?
If W is in W, then W contains itself. But W contains only those sets that dont contain themselves. So W is not in W. If
W is not in W, then W does not contain itself. But W contains those sets that dont contain themselves. So W is in W.
Whats wrong???
BARBERS PARADOX
There is a male barber who shaves all those men, and only those men, who do not shave themselves.
HALTING PROBLEM
Now we mention one of the most famous problems in computer science.
The halting problem: Can we write a program which detects infinite loop?
We want a program H that given any program P and input I:
H(P,I) returns halt if P will terminate given input I;
H(P,I) returns loop forever if P will not terminate given input I.
And H itself must terminate in finite time.
BASIC COUNTING
SUM RULE
|S|: the number of elements in a set S.
PRODUCT RULE
Recall that, given two sets A and B, the Cartesian product: A X B={ ( a , b )| a Ab B }
Example: If there are 4 men and 3 women, there are possible married couples.
Fact: If |A| = n and |B| = m, then |AxB| = mn.
In general let A = {a1, a2, a3, , am} and B = {b1, b2, , bn}. We can arrange the elements into a table as follows.
A B = {(a1,b1), (a1,b2) ,, (a1,bn), (a2,b1), (a2,b2),, (a2,bn), (a3,b1), (a3,b2),, (a3,bn), , (am,b1), (am,b2),, (am,bn)}
There are m rows, and each row has n elements, and so there are a total of mn elements.
Let B={0,1} the set of 2-bit strings is just BxB. The set of 10-bit strings is just BxBxBxBxBxBxBxBxBxB, denoted by
B10.
By the product rule, |BxB| = |B|x|B| = 2x2 = 4, and |B 10| = |B|x|B|x|B|x|B|x|B|x|B|x|B|x|B|x|B|x|B| = |B| 10 = 210 =
1024.
EXAMPLE: IP ADDRESSES
What is the number of IP addresses?
An IP address is of the form 192.168.0.123. There are four numbers, each is between 0 and 255.
Let B={0,1,,255}. Then the set of IP addresses is just B 4. By the product rule, |B4| = |B|4 = 2564 = 4294967296.
L x ( LD )5
Pn
=length n passwords
L x ( LD )n1
L Dn1
|L x ( L D )n1|=| L| by product rule
|L|+ D
by sum rule
|L|
n1
56 62
186125210680448
19 1014
Method 1
count by 1st occurrence of 7:
7xxx + o7xx + oo7x + ooo7
where x represents any digit from 0 to 9,
The set of 4-digit while o represents any digit from 0 to 9 except 7.
numbers with 7 in Clearly, each number containing at least one 7 is in
the first digit. one of the above sets, and these sets are disjoint.
The set of 4-digit numbers Therefore, the answer to the question is:
with 7 in the second digit, but 103 + 9102 + 9210 + 93 = 3439
(counting by partitioning)
How many # 4-digit numbers with at least one 7?
Method 2
|4-digit numbers with at least one 7| = |4-digit numbers| - |those with no 7s|
= 104 94
= 3439
(counting the complement)
DEFECTIVE DOLLARS
A dollar is defective if some digit appears more than once in the 6-digit serial number.
10 possible choices for the first digit, 9 possible choices for the second digit, and so onSo, there are
10x9x8x7x6x5 = 151200 serial numbers with all its digit different. There are totally 10 6 = 1000000 serial numbers.
So, only about 15% of dollars are non-defective.
then, |Q|=n1 n2 n3 n k
PERMUTATIONS
Definition: A permutation of a set S is a sequence that contains every element of S exactly once.
For example, here are all six permutations of the set {a, b, c}:
(a, b, c) (a, c, b) (b, a, c)
(b, c, a) (c, a, b) (c, b, a)
There are n choices for the first element. For each of these, there are n 1 remaining choices for the second
element. For every combination of the first two elements, there are n 2 ways to choose the third element, and so
forth. Thus, there are a total of n (n 1) (n 2) 3 2 1 = n! permutations of an n-element set.
n
e
Stirlings formula:
n ! 2 n
EXAMPLE: PERMUTATION
Suppose each digit is an element in {1,2,3,4,5,6,7,8,9}. How many 9-digit numbers are there where each nonzero
digit appears once?
Each such number corresponds to a permutation of 123456789, and each permutation corresponds to such a
number. So the numbers of such numbers is equal to the number of permutations of {1,2,3,4,5,6,7,8,9}. Hence
there are exactly 9! such numbers. Alternatively, one can use the generalized product rule directly to obtain the
same result.
COMBINATIONS
How many subsets of size k of an n-element set?
So far we counted the number of ways to choose k elements, when the ordering is important.
e.g. {1,2,3}, {1,3,2}, {2,1,3}, {2,3,1}, {3,1,2}, {3,2,1} will be counted as 6 different ways.
e.g. If we are forming subsets of size 3, then (1,2,3), (1,3,2), (2,1,3), (2,3,1), (3,1,2), (3,2,1) are counted as 6
different ways if the ordering is important.
In general, each subset of size k has k! different orderings, and so each subset is counted k! times in the above way
of choosing k elements.
Each subset is counted, but is counted k! times, because each subset contributes k! different orderings to
the above.
So, when the ordering is not important, the answer is:
We can think of this problem as choosing k positions (out of the n possible positions) and set them to zeroes and set
the remaining positions to ones. So the above question is asking the number of possible positions of the k zeros,
If n is odd, then every n-bit string is unbalanced, and the answer is 2n.
n
If n is even, then the number of balanced strings is ( by choosing n/2 positions to zeroes.
n/2
So the number of unbalanced n-bit strings is equal to the number of all n-bit strings minus the number of balanced
n
strings, and so the answer is 2n - (
n/ 2
POKER HANDS
There are 52 cards in a deck. Each card has a suit and a value.
4 suits ( )
13 values (2, 3, 4, 5, 6, 7, 8, 9, 10, J, Q, K, A)
Five-Card Draw is a card game in which each player is initially dealt a hand, a subset of 5 cards.
One way to do this is to first map the problem into a problem of counting sequences.
Double Count!
So the answer is
Double count!