Probability Basics

Sample space, events, P(A or B), P(A and B), complement rule, and independent vs dependent events.

62 lessons
192 min
Codeforces: 1100-1500LeetCode: 1400-1700

Lessons

1. Intro

(The Goal)

2m

2. Sample Space

(All possible outcomes)

4m

3. Outcomes

(Individual results)

4m

4. Events

(Subsets of the sample space)

4m

5. Probability Formula

(Favorable over total)

3m

6. Example - Rolling a Die

(Probability of rolling > 4)

2m

7. Probability Bounds

(Always between 0 and 1)

3m

8. Complement Rule

(Probability of "not A")

4m

9. Example - Complement

(At least one head in 3 flips)

3m

10. Union of Events

(A or B happens)

3m

11. Addition Rule

(P(A or B) formula)

3m

12. Intersection of Events

(A and B both happen)

3m

13. Example - Union and Intersection

(Card draw probabilities)

3m

14. Mutually Exclusive Events

(Cannot happen together)

3m

15. Example - Mutually Exclusive

(Rolling 2 or 5)

3m

16. Independent Events - Intro

(One does not affect the other)

3m

17. Multiplication Rule

(P(A and B) for independent events)

3m

18. Example - Independent Events

(Two dice rolls)

2m

19. Dependent Events - Intro

(One affects the other)

3m

20. Conditional Probability

(Probability given something happened)

3m

21. Example - Conditional Probability

(Cards without replacement)

3m

22. General Multiplication Rule

(Works for dependent events)

3m

23. Quiz: Basic Probability

(Knowledge check)

2m1 problems

24. Expected Value - Intro

(Average outcome over many trials)

3m

25. Expected Value Formula

(Weighted average)

3m

26. Example - Expected Die Roll

(Fair six-sided die)

3m

27. Expected Value - Unfair Outcomes

(Different probabilities)

3m

28. Applications in CS

(Why probability matters)

4m

29. Randomized Algorithms

(Using probability for speed)

4m

30. Hash Collisions

(Birthday paradox in hash tables)

4m

31. Problem - Two Dice Sum

(Read statement)

2m1 problems

32. Two Dice - Sample Space

(36 outcomes)

3m

33. Two Dice - Event

(Sum equals 7)

2m

34. Two Dice - Answer

(P = 1/6)

2m

35. Problem - Birthday Paradox

(Read statement)

2m1 problems

36. Birthday - Complement Approach

(Easier to count no match)

3m

37. Birthday - Calculation

(Multiply probabilities)

3m

38. Birthday - Insight

(Why it is surprising)

3m

39. Problem - Weighted Random

(LeetCode 528)

2m1 problems

40. Weighted Random - Idea

(Convert weights to ranges)

3m

41. Weighted Random - Prefix Sum

(Build cumulative array)

3m

42. Weighted Random - Binary Search

(Find the range)

3m

43. Weighted Random - Implementation

(Python code)

5m

44. Quiz: Independence and Expected Value

(Knowledge check)

2m1 problems

45. Practice Problems

(Apply what you learned)

4m

46. Problem - Linked List Random Node

Uniform random selection

2m1 problems

47. Linked List Random Node - Insight

Reservoir sampling idea

4m

48. Linked List Random Node - Implementation

The pseudocode

4m1 problems

49. Problem - Shuffle an Array

Fair randomization

2m1 problems

50. Shuffle - Fisher-Yates Algorithm

The standard solution

5m

51. Shuffle - Implementation

The code

5m1 problems

52. Lessons from Shuffle

summary

2m

53. Problem - Random Pick with Weight

Weighted random selection

2m1 problems

54. Weighted Pick - Prefix Sum

Converting weights to ranges

4m

55. Weighted Pick - Binary Search

Finding the target range

4m

56. Weighted Pick - Implementation

The code

5m1 problems

57. Lessons from Weighted Pick

summary

2m

58. Problem - Random Pick Index

Reservoir sampling variant

2m1 problems

59. Pick Index - Reservoir Sampling

Fair selection in one pass

5m

60. Pick Index - Implementation

The code

5m1 problems

61. Lessons from Pick Index

summary

2m

62. Section Recap

What we learned

2m

Ready to start learning?

Access all 62 lessons with interactive content and progress tracking.