Expected Number of Connected Components in a Random Coloring

EasyProbability

Reported in interviews at Akuna Capital Citadel Five Rings Virtu Financial

Problem statement

You have $n = 100$ squares arranged in a line. Each square is independently colored black or white with equal probability $\frac{1}{2}$.

A connected component is a maximal run of adjacent squares sharing the same color. For example, the sequence BBWWBBBWBWWW has 6 connected components.

What is the expected number of connected components when $n = 100$?

Show hint

Can the number of components be written as a sum of simple yes/no events along the line?

Relevant roles: Data Scientist, Applied Scientist and Research Scientist.

Related free problems