Lecture 02/02/2026 - Independence, Geometric Random Variables, and Hashing
Scribes: Joshua Sin and Ye Htut Muang
Summary of the Lecture
Section titled “Summary of the Lecture”- Geometric Random Variables, what are they and how are they useful
- The Coupon Collector Problem, its problem statement and how we can solve it using geometric random variables
- The Membership/Dictionary Problem, its problem statement and how we can solve it using hashing with chaining
- What is hashing with chaining and how we can use it to solve the Membership/Dictionary Problem
Independence
Section titled “Independence”Types of Independence
Section titled “Types of Independence”For a sequence of random variables
(1) Pairwise independence
(2) Mutual independence
Pairwise Independence / 2-wise Independence
Section titled “Pairwise Independence / 2-wise Independence”Mutual Independence / n-wise Independence
Section titled “Mutual Independence / n-wise Independence”Finding all but
Linearity of Variance for a Sequence of Random Variables
Section titled “Linearity of Variance for a Sequence of Random Variables”For any independent random variables
Suppose
By applying linearity of variance, let
Geometric Random Variable
Section titled “Geometric Random Variable”Say we have a coin which turns up heads with probability
Expectation - Alternative Definition
Section titled “Expectation - Alternative Definition”Expectation and Variance of Geometric Random Variable
Section titled “Expectation and Variance of Geometric Random Variable”Coupon Collector Problem
Section titled “Coupon Collector Problem”Pokemon Character Example
Section titled “Pokemon Character Example”Let there be 20 unique characters in Pokemon. Pokemon is collaborating with a cereal company, and when you buy cereal, you get one Pokemon character randomly. How many boxes of cereal in expectation do you need to buy to get all 20 Pokemon characters?
Let’s start with a simple question: If I already have 19 characters, what is the chance that I get the 20th unique character in my next cereal box? The answer is
Now, let’s find the pattern of the probability of each case, as the probability will change every time we pick a new character:
- If we have 0 characters, we have
or 100% chance that we get a new character. - If we have 1 character, we have
chance that we get a new character. - If we have 2 characters, we have
chance that we get a new character. - If we have 19 characters, we have
chance that we get a new character.
Let
= the number of boxes bought before the 1st new character; and = the number of boxes bought after getting the 1st character but before the 2nd new character; and = the number of boxes bought after getting the 2nd character but before the 3rd new character; and = the number of boxes bought after getting the 19th character but before the 20th new character; and
Now, we find the expectation of the total number of cereal boxes we need to buy to get all 20 Pokemon characters:
Since
When we talk about expected runtime, it will be
Generalization of Coupon Collector Problem
Section titled “Generalization of Coupon Collector Problem”By the linearity of expectation, the total expected number of boxes
Since
Membership/Dictionary Problem
Section titled “Membership/Dictionary Problem”Problem Statement
Section titled “Problem Statement”In the membership/dictionary problem, we have a set
Methods to Solve
Section titled “Methods to Solve”Brute Force: We take
- Runtime:
Binary Search: First, we sort
- Runtime:
Is it possible to solve this problem and achieve constant querying time (
Algorithm 1 - Hashing with Chains
Section titled “Algorithm 1 - Hashing with Chains”Given a hash function
Algorithm:
(1) Initialize
(2) For
- compute
- append
to the linked list in bucket
Note: Query time depends on which bucket you have to search.
Example
Section titled “Example”Suppose we want to support membership queries on the set
using a hash table of size
Each table entry stores a chain of elements that hash to the same index.
| Index | Stored Keys |
|---|---|
| 0 | 5 |
| 1 | (empty) |
| 2 | |
| 3 | (empty) |
| 4 | (empty) |
To answer a membership query for a key
Example Queries
Section titled “Example Queries”- Query
: . Searching the chain at index 2 finds 22, so . - Query
: . The chain at index 4 is empty, so .