Personal notes for programming
- To find if a connected graph is cyclic simple do a bfs and check if the number of visited adjacent nodes for ant node are greater than 2 then the graph contains cycle.
- Some important values-2^10 approx 10^3 ,2^20 approx 10^6
- Important modular arithmetic formulas-
(A + B) % P = (A % P + B % P) % P
(A * B) % P = (A % P * B % P) % P
(a - b) mod p = ((a mod p - b mod p) + p) mod p
(a / b) mod p = ((a mod p) * (b^(-1) mod p)) mod p
p = prime, b^(-1) mod p = b^(p - 2) mod p
- Combinatorics imp points:-
consider the set . There are total subsets (of all sizes), which are
(Imp see that only {1,2} is there not {2,1})
To count undirected loopless graphs with no repeated edges, first count possible edges. As Andre counts, there are such edges. One by one, each edge is either included or excluded. So this gives possible graphs.
If loopless graphs with no repeated edges are directed, each pair of vertices provides possibilities for a (potentially absent) edge. So we have 3 choices (a,b) (b,a) and not present.
Comments
Post a Comment