Discrete Math for Computer Science - Counting & Probability
Keep adding new skills with 10,000+ programs for $239 (usually $399). Save now.
Discrete Math for Computer Science - Counting & Probability
This course is part of Discrete Mathematical Tools for Computer Science Specialization
Instructor: Kenneth Wai-Ting Leung
Included with
Ask Coursera
Recommended experience
Recommended experience
What you'll learn
Use propositional and predicate logic to model and reason about computer science problems.
Use permutations, combinations, and inclusion–exclusion to solve combinatorial problems.
Analyse uncertainty using probability, conditional probability, and random variables.
Skills you'll gain
Details to know
February 2026
7 assignments
See how employees at top companies are mastering in-demand skills
Build your subject-matter expertise
- Learn new concepts from industry experts
- Gain a foundational understanding of a subject or tool
- Develop job-relevant skills with hands-on projects
- Earn a shareable career certificate
There are 8 modules in this course
This course develops the mathematical tools needed to count, measure uncertainty, and reason about random processes, which are central to computer science, data analysis, and algorithm design. Building on the logical foundations from the first course, it introduces combinatorial counting techniques and probability theory through a discrete, computation-oriented lens.
The course begins with the fundamentals of counting, including the product rule, sum rule, permutations, combinations, and binomial coefficients. You will learn how to count complex structures efficiently using techniques such as the principle of inclusion and exclusion, with applications ranging from algorithm analysis to data organization. The second half of the course focuses on probability, emphasizing its deep connection to counting. Topics include sample spaces, events, conditional probability, independence, and Bayes’ Theorem. You will also study random variables, probability distributions, expectation, and variance, gaining tools to model and analyze randomized algorithms and real-world uncertainty. Throughout the course, abstract concepts are reinforced with concrete examples drawn from computing, games of chance, and classic probability puzzles. By the end, learners will be able to systematically count possibilities, compute probabilities, and reason rigorously about randomness—skills essential for advanced study in algorithms, data science, machine learning, and beyond.
This module teaches how to count arrangements, selections, and possibilities using permutations, combinations, binomial coefficients, and inclusion-exclusion. It covers probability fundamentals, conditional probability, random variables, and iconic problems like the Monty Hall dilemma to handle uncertainty. These tools are crucial for analyzing algorithm efficiency, game design, randomized systems, machine learning, and risk assessment.
What's included
1 reading
1 reading•Total 10 minutes
- Introduction to Discrete Math for Computer Science (Counting & Probability)•10 minutes
Counting techniques provide systematic methods for determining the number of possible outcomes in discrete structures. This topic introduces basic counting principles such as the sum rule and product rule.
What's included
15 videos1 reading1 assignment
15 videos•Total 41 minutes
- Basics of Counting Overview•3 minutes
- Basics of Counting_intro•8 minutes
- Product Rule_Intro, Example1 & 2•1 minute
- (Optional) Product Rule_Example3 & 4•2 minutes
- (Optional) Product Rule_Example5 & 6•2 minutes
- Sum Rule_Example•1 minute
- (Optional) Using Both Product and Sum Rules_Example1•2 minutes
- (Optional) Using Both Product and Sum Rules_Example2•3 minutes
- (Optional) InclassEx•2 minutes
- Tree Diagrams_Intro, Example1 & 2•3 minutes
- The Pigeonhole Principle_Intro & Example1•2 minutes
- (Optional) The Pigeonhole Principle_Example2•2 minutes
- (Optional) The Pigeonhole Principle_Example3•3 minutes
- The Pigeonhole Principle_Generalized Pigeonhole Principle_Intro & Example1•3 minutes
- (Optional) The Pigeonhole Principle_Generalized Pigeonhole Principle_Example2 & 3•5 minutes
1 reading•Total 30 minutes
- Basics of Counting•30 minutes
1 assignment•Total 20 minutes
- Quiz 1•20 minutes
This topic studies methods for counting arrangements and selections of objects. It distinguishes between ordered and unordered selections and introduces formulas for permutations and combinations.
What's included
16 videos1 reading1 assignment
16 videos•Total 65 minutes
- Permutations and Combinations Overview•2 minutes
- Permutations and Combinations_intro•1 minute
- (Optional) Permutations_Example1•4 minutes
- Permutations_Number of k-Permutations•3 minutes
- (Optional) Permutations_Example2 & 3•1 minute
- Permutations_Permutation & k-Permutation Definition•2 minutes
- (Optional) Permutations_Example4 & 5 & 6•3 minutes
- (Optional) Permutations_Example7•6 minutes
- Combinations_Intro & k-Combinations, Proof•7 minutes
- (Optional) Combinations_Example1 & 2•9 minutes
- Combinations_Combinatorial Proof and Bijection Principle_Intro & Examples•5 minutes
- Generalized Permutations and Combinations_Permutations with Indistinguishable Objects_Intro & Example•4 minutes
- Generalized Permutations and Combinations_Distributing Objects into Boxes_Intro & Example•2 minutes
- Generalized Permutations and Combinations_Indistinguishable objects Distinguishable boxes_Theorem & Example•8 minutes
- Generalized Permutations and Combinations_Combinations with Repetition_Intro & Examples•3 minutes
- (Optional) InclassEx•5 minutes
1 reading•Total 30 minutes
- Permutations and Combinations•30 minutes
1 assignment•Total 20 minutes
- Quiz 2•20 minutes
Binomial coefficients arise in counting combinations and in the expansion of binomial expressions. This topic covers the binomial theorem, Pascal’s identity, and important combinatorial identities.
What's included
13 videos1 reading1 assignment
13 videos•Total 59 minutes
- Binomial Coefficients Overview•3 minutes
- Binomial Coefficients_Intro•1 minute
- Binomial Theorem_Example1, Definition & Proof•6 minutes
- (Optional) Binomial Theorem_Example2 & 3•1 minute
- Binomial Theorem_Corollary1 & Combinatorial Proof•7 minutes
- Binomial Theorem_Corollary2 & Pascal’s Triangle•4 minutes
- Binomial Theorem_Corollary3•1 minute
- Pascal’s Identity and Triangle_Pascal's Identity & Combinatorial proof of Pascal’s identity•11 minutes
- Pascal’s Identity and Triangle_Pascal’s Triangle•1 minute
- Some Other Identities_Vandermonde's Identity•6 minutes
- Some Other Identities_Vandermonde's Identity_Corollary•3 minutes
- Some Other Identities_Counting bit strings & Proof•9 minutes
- (Optional) InclassEx•5 minutes
1 reading•Total 30 minutes
- Binomial Coefficients•30 minutes
1 assignment•Total 30 minutes
- Quiz 3•30 minutes
The inclusion–exclusion principle provides a systematic way to count elements in overlapping sets. It is widely used in counting problems involving unions of multiple sets.
What's included
13 videos1 reading1 assignment
13 videos•Total 78 minutes
- The Inclusion-Exclusion Principle Overview•3 minutes
- The Inclusion-Exclusion Principle_Intro•1 minute
- Two Finite Sets_Intro & Examples•3 minutes
- Three Finite Sets_Intro•3 minutes
- (Optional) Three Finite Sets_Example•2 minutes
- Inclusion-Exclusion Principle_Theorem•6 minutes
- Inclusion-Exclusion Principle_Proof•8 minutes
- Number of Onto Functions_Intro & Example1•14 minutes
- (Optional) Number of Onto Functions_Example2•2 minutes
- Derangement_Example1 & Proof•15 minutes
- (Optional) Derangement_Example2•2 minutes
- Probability of a derangement•3 minutes
- (Optional) InclassEx•18 minutes
1 reading•Total 30 minutes
- The Inclusion-Exclusion Principle•30 minutes
1 assignment•Total 20 minutes
- Quiz 4•20 minutes
This topic introduces probability as a measure of uncertainty based on counting outcomes. It defines experiments, sample spaces, events, and basic probability rules.
What's included
21 videos1 reading1 assignment
21 videos•Total 68 minutes
- Introduction to Probability Overview•2 minutes
- The Hatcheck Problem Revisited•1 minute
- Probability_Definitions•2 minutes
- (Optional) Probability_Example•2 minutes
- Poker_Intro•3 minutes
- (Optional) Poker_Ex1•4 minutes
- (Optional) Poker_Ex2•6 minutes
- (Optional) Poker_Ex3•5 minutes
- (Optional) Poker_Ex4•4 minutes
- Mark Six•4 minutes
- Sampling with/without replacement•1 minute
- Complement of Event_Theorem•2 minutes
- (Optional) Complement of Event_Example•2 minutes
- Union of Events & Inclusion-Exclusion Principle for Probability, Complement and Union Events•4 minutes
- Probability Distribution•2 minutes
- Uniform Distribution & Non-Uniform Distribution•2 minutes
- Probability of an Event•2 minutes
- Independence_Definition•2 minutes
- (Optional) Independence_Examples•6 minutes
- Pairwise and Mutual Independence•6 minutes
- (Optional) InclassEx•6 minutes
1 reading•Total 10 minutes
- Introduction to Probability•10 minutes
1 assignment•Total 20 minutes
- Quiz 5•20 minutes
Conditional probability measures the likelihood of events given prior information. This topic introduces independence and Bayes’ theorem, enabling probabilistic reasoning in real-world decision making.
What's included
15 videos1 reading1 assignment
15 videos•Total 69 minutes
- Conditional Probability and Bayes' Theorem Overview•5 minutes
- Conditional Probability and Bayes' Theorem_Intro•1 minute
- Conditional Probability•6 minutes
- (Optional) Conditional Probability_Example1•3 minutes
- (Optional) Conditional Probability_Example2•4 minutes
- Conditional Probability_The Birthday Problem•4 minutes
- Independence Revisited•3 minutes
- Independence Example Revisited•2 minutes
- Bayes’ Theorem_Theorem & Example1, Explanation•10 minutes
- (Optional) Bayes’ Theorem_Example2•1 minute
- (Optional) Bayes’ Theorem_Example3•5 minutes
- Bayesian Spam Filter_Intro & Example•4 minutes
- Generalized Bayes’ Theorem_Theorem & Example•2 minutes
- Monty Hall Problem•12 minutes
- (Optional) InclassEx•6 minutes
1 reading•Total 30 minutes
- Conditional Probability and Bayes' Theorem•30 minutes
1 assignment•Total 20 minutes
- Quiz 6•20 minutes
Random variables assign numerical values to outcomes of random experiments. This topic covers discrete and continuous distributions, expectation, and variance, forming the foundation of probability modeling.
What's included
28 videos1 reading1 assignment
28 videos•Total 132 minutes
- Random Variables Overview•3 minutes
- Random Variables•2 minutes
- Distribution of a Random Variable•1 minute
- Bernoulli Trials•4 minutes
- Binomial Distribution_Theorem & Example•3 minutes
- Continuous Probability Distribution•3 minutes
- Infinite Sample Space•3 minutes
- Geometric Distribution•2 minutes
- Expected Value_Definition, Theorem & Example•8 minutes
- Expected Value_Example_Binomial Distribution•2 minutes
- Linearity of Expectations_Theorem & Proof•4 minutes
- Indicator Random Variables_Intro•3 minutes
- (Optional) Indicator Random Variables_Example_the Hatcheck Problem•4 minutes
- (Optional) Indicator Random Variables_Example_Hiring Problem•15 minutes
- (Optional) Indicator Random Variables_Example_Balls and Bins•4 minutes
- Average-case Analysis of Algorithms_Definition & Example_Linear Search•8 minutes
- (Optional) Average-case Analysis of Algorithms_Example_Insertion Sort•8 minutes
- Geometric Distribution_Definition & Theorem•2 minutes
- (Optional) Geometric Distribution_Example_Coupon Collector•7 minutes
- Independent Random Variables_Definition, Theorem & Proof•9 minutes
- (Optional) Independent Random Variables_Example•6 minutes
- Variance and Standard Deviation_Definition•8 minutes
- Variance_Theorem•2 minutes
- (Optional) Variance_Example•3 minutes
- Bienaymé’s Formula_Theorem & Proof•3 minutes
- (Optional) Bienaymé’s Formula_Example1•3 minutes
- (Optional) Bienaymé’s Formula_Example2•6 minutes
- (Optional) InclassEx•6 minutes
1 reading•Total 30 minutes
- Random Variables•30 minutes
1 assignment•Total 20 minutes
- Quiz 7•20 minutes
Earn a career certificate
Add this credential to your LinkedIn profile, resume, or CV. Share it on social media and in your performance review.
Instructor
Explore more from Algorithms
- Status: Free TrialU
University of California San Diego
Course
- Status: Free TrialT
The Hong Kong University of Science and Technology
Course
- Status: Free TrialT
The Hong Kong University of Science and Technology
Course
- Status: Free TrialB
Birla Institute of Technology & Science, Pilani
Course
Why people choose Coursera for their career
Frequently asked questions
To access the course materials, assignments and to earn a Certificate, you will need to purchase the Certificate experience when you enroll in a course. You can try a Free Trial instead, or apply for Financial Aid. The course may offer 'Full Course, No Certificate' instead. This option lets you see all course materials, submit required assessments, and get a final grade. This also means that you will not be able to purchase a Certificate experience.
When you enroll in the course, you get access to all of the courses in the Specialization, and you earn a certificate when you complete the work. Your electronic Certificate will be added to your Accomplishments page - from there, you can print your Certificate or add it to your LinkedIn profile.
Yes. In select learning programs, you can apply for financial aid or a scholarship if you can’t afford the enrollment fee. If fin aid or scholarship is available for your learning program selection, you’ll find a link to apply on the description page.
More questions
Financial aid available,
