All courses › Discrete Mathematics
Discrete Mathematics: free practice, theory and problems
Computers are built on logic: true and false, and and or. Sets are how mathematics collects things. Both show up everywhere in programming, databases and digital circuits.
Contents
1. Logic and sets
What is it about?
Computers are built on logic: true and false, and and or. Sets are how mathematics collects things. Both show up everywhere in programming, databases and digital circuits.
Concepts and formulas
- Propositional logic: (not), (and), (or), (if … then).
- is only false when is true and is false.
- De Morgan's laws:
- Contrapositive: is equivalent to .
- A truth table with variables has rows.
- Sets: union (in A or B), intersection (in both), complement.
- Inclusion–exclusion:
- A set with elements has subsets (the power set).
How to solve the problems
- Logic: make a truth table, or use De Morgan and the contrapositive.
- Counting with overlap: add and subtract what was counted twice.
- "Neither": total minus the union.
Example
40 students: 25 take maths, 18 take physics and 10 take both. How many take neither?
- .
- Neither: .
Common mistakes
- Thinking is false when is false. A promise is not broken if the condition doesn't happen.
- Forgetting to subtract the intersection and so counting some twice.
- Confusing the converse () with the contrapositive.
Concepts in this part
2. Combinatorics
What is it about?
How many passwords exist? In how many ways can a team be chosen? Combinatorics is systematic counting. It is used in probability, security (how long does it take to guess a password?) and algorithms (how many cases must be checked?).
Concepts and formulas
- Multiplication principle: choices followed by choices give possibilities.
- Ordered selections with repetition: (for example a PIN code).
- Permutations: things in order: .
- Ordered selection without repetition (order matters):
- Combinations (order doesn't matter):
- Handshakes between people: .
How to solve the problems
- Ask: does order matter? Can the same thing be chosen more than once?
- Order and repetition: . Order without repetition: . No order: .
Example
8 runners compete for gold, silver and bronze. How many possible podiums are there?
- The order matters, and nobody can get two medals.
- .
Common mistakes
- Using combinations when the order matters (or the other way round).
- Forgetting that .
- Adding when the choices should be multiplied.
Concepts in this part
3. Graphs and modular arithmetic
What is it about?
A graph is nodes (points) connected by edges (lines). Road networks, computer networks, friends on social media and dependencies between program modules are all graphs. Modular arithmetic is "clock arithmetic" with remainders, used in hashing, encryption and check digits.
Concepts and formulas
- The degree of a node: the number of edges leaving it. Handshake lemma:
- The complete graph (everyone connected to everyone) has edges.
- A tree is a connected graph without cycles. A tree with nodes has exactly edges.
- Euler circuit (use every edge exactly once and return): exists when the graph is connected and every node has even degree.
- Shortest path in a weighted graph: Dijkstra's algorithm. Always expand from the nearest node you haven't finished.
- Modular arithmetic: is the remainder when is divided by . For example .
How to solve the problems
- Count edges via the degrees: add up and divide by 2.
- For trees and complete graphs: use the formulas.
- Shortest path: try all reasonable routes in small graphs, or follow Dijkstra.
Example
Edges: A–B (4), A–C (1), C–B (2), B–D (5), C–D (8). Shortest path from A to D?
- A–C–B costs , which is cheaper than A–B directly (4).
- Then B–D: . The alternative A–C–D costs .
- The shortest path is A–C–B–D with length 8.
Common mistakes
- Forgetting to divide the degree sum by 2.
- Thinking the direct edge is always shortest.
- Using negative remainders: in mathematics is always between 0 and .
Concepts in this part
Example problems with solutions
Here are some of the problems in discrete Mathematics. In the app, calculation problems get new numbers every time, so you can practise until it sticks – and take a graded practice exam before the real one.
Logic and sets: When is the implication false?
Answer: When is true and is false
The implication promises that follows when holds. That promise is only broken when happens and does not.
Combinatorics: You have 3 shirts and 4 pairs of trousers. How many outfits can you make?
Answer: 12
Multiplication principle: .
Graphs and modular arithmetic: A graph has 7 edges. What is the sum of the degrees of all the nodes?
Answer: 14
Each edge adds 2 to the degree sum: .
Logic and sets: , and . What is ?
Answer: 30
.
Matches these university courses
The content covers the syllabus found in engineering degrees, for example:
- TMA4140 (NTNU)