Bite-Sized Mathematics for Computer Science

Notes on MIT's 6.042J

Eda Eren
Table of Contents

Introduction

Prerequisites & Resources

Unit 1: Proofs

00. Introduction to Proofs

01. (Two) Proof Methods

02. The Well Ordering Principle

03. Logic & Propositions

04. Quantifiers and Predicate Logic

05. Sets

06. Binary Relations

07. Induction

08. State Machines — Invariants

09. Recursive Definitions

10. Infinite Sets

Unit 2: Structures

11. GCDs

12. Congruences

13. Euler's Theorem

14. RSA Encryption

15. Digraphs: Walks and Paths

16. Directed Acyclic Graphs

17. Partial Orders and Equivalence

18. Degrees & Isomorphism

19. Coloring & Connectivity

20. Trees

21. Stable Matching

Unit 3: Counting

22. Sums & Products

23. Asymptotics

25. Repetitions & Binomial Theorem

26. Pigeonhole Principle, Inclusion-Exclusion

Unit 4: Probability

27. Intro to Discrete Probability

28. Conditional Probability

29. Independence & Causality

30. Random Variables, Density Functions

31. Expectation

32. Deviation: Markov & Chebyshev Bounds

33. Sampling & Confidence

34. Random Walks & PageRank

Counting with Bijections

There is a way to count one thing by counting another.

That's not a "zen quote." What it implies is that counting one thing by counting another is to find a bijection between them.
(On second thought, it could be a zen quote.)

The reason that it works is that when there is a bijection between two sets, that means the sets are of the same size. This is known as the Bijection Rule.

We did one example already (Why is the size of a power set is 2n2^n?) in sets, where we counted the number of subsets of a set by counting the number of nn-bit string representations. That example pretty much covers this concept.


The sum rule is obvious. If we have two disjoint sets AA and BB, the size of their union is the sum of the size of AA and the size of BB: AB=A+B|A \cup B| = |A| + |B|.

Say, we can only use lowercase letters, uppercase letters, and digits for a password. Considering that the letters are only from the English alphabet, how many possible characters can we use?

Well, there are 2626 letters and 1010 digits (00-99), so the number of possible characters is 26+26+1026 + 26 + 10, which is 6262.


The product rule is also a clear concept. The size of the product of two sets AA and BB will be the product of their sizes.

If A=m and B=n|A| = m \text{ and } |B| = n, then

A×B=mn|A \times B| = m \cdot n

Let's say that set AA is {1, 2, 3}\{1, \ 2, \ 3\}. Set BB is {a, b}\{a, \ b\}.
Their product is {(1, a), (1, b), (2, a), (2, b), (3, a), (3, b)}\{(1, \ a), \ (1, \ b), \ (2, \ a), \ (2, \ b), \ (3, \ a), \ (3, \ b)\}.
The size of AA is 33, the size of BB is 22, and the size of their product is 32=63 \cdot 2 = 6.