离散数学重要知识
乘法原则:
每一步都是相互独立的,互不影响
顺序是有关的
通常枚举枚举每一步的情况,然后把他乘起来
减法思维: (do what we don't want)
当正面想不出来的时候,就利用反面去想
往往是比较简单的
但是现在我的第一反应就是反面思维,有时正面思维是更简单的, (在乘法原则的时候)
加法原则:
每一部都是互斥的,没有交集,
然后把这些部分全部加起来,就彳于了
|A1 ∪A2| = |A1|+|A2| −|A1 ∩A2|
通常用于 or 的情况, 即:2个部分不是互斥的, 需要减去交集的情况
选择:
注意是否可以 重复, 顺序是否重要
Permutations:
order matter , can't repert
P(n, k)
Combinations:
order does't matter, repert not allowed
还用于 顺序,两两之间排序顺寻定下来的队列, 直接选数就完了
C(n, k)
Combinations with Unlimited Repetition:
order does't matter, repert allowed
C(k +n−1, k)
重要例子:
x1+x2+x3+x4+x5=30
排板法:
把球分完, 每一个盒子的球数量,无所谓(不需要相同)
有几个可以插的地方,很关键
$(a+b)n=C(n,k)ak*b^(n-k)$
注意系数
所有那个相加是 $2^n$
Pascal’s Identity
Vandermonde’s Identity
The Pigeonhole Principle
If n pigeons fly into k pigeonholes, then
some pigeonhole contains at least $n/k$(向上取整) pigeons.
相当于,每一个洞均摊
概率
重点就是注意格式
A = event that at least two people have the same birthday
A = event that no two people have the same birthday
|S| = 365n
|A| = 365 · 364 · ... ·(365−n+1)
Conditional Probability
P(A|E)=A&&E/E
Independent Events
$P(A∩B) = P(A)P(B)$
Bayes’ Theorem
就利用乘法除法,倒来倒去就彳于了
图论
Graph Models
$G = (V(G),E(G)) $
$G = (V(G),E(G))
V(G) = {v1, v2, v3, v4, v5}
E(G) = {v1v2, v2v3, v3v4, v1v4, v2v4, v4v5}$
A simple graph 无自环无重边
Vertex Degree 入读出度算作一起
所有的度加起来算作边的2倍
因此度数的和一定是偶数
因此the number of vertices of odd degree is even
遇到问题多从度的角度去解决问题
Euler’s Theorem
欧拉循环,全是偶数度
欧拉路, 当且仅当2个点是奇数度
Bipartite Graphs
成立的时候,没有一个奇数环
Every odd closed path contains an odd simple cycle
Every tree with at least two vertices has at least two leaves.
Let G be a connected graph. An edge e is not a cut-edge if and only if it belongs to a cycle.
Isomorphic graph
import info
- A simple path from vertex u to vertex v in a graph G is a path from u to v with no repeated vertice
- Lemma 3.1 Let G be a graph, and u and v two vertices of G. There is a path from u to v in G if and only if there is a simple path from u to v in G
- proof : 不断收缩的思想,找到一个重复的节点
- A graph G is connected if for every pair of vertices u and v of G there is a path from u to v. Otherwise G is disconnected
- Let G be a graph and v a vertex of G. A cycle is a path of nonzero length from v to v with no repeated edges The length of a cycle is the number of edges it contains.
- A simple cycle is a cycle from v to v in which, except for the beginning and ending vertices that are both equal to v, there are no repeated vertices.
- A cycle in a graph G that includes all of the edges and all of the vertices of G is called an Euler cycle
- without repeating edges. !!!
- 重点就是 contradiction --- base case Induction Step
- A tree is a connected graph with no cycles
1 点和点的度数
2 直接证明他的映射关系
小细节:
- 当选数字作为数位的时候, 0是要选的,而且0不能做开头!!
- 特别注意2个事件的&& || 关系, 到底是怎么样子的, 比如减法的时候