Let $Q = (A, p)$ be a source with $n$ symbols $a_1,\ldots,a_n$ and their probabilities $p_1 \ge \cdots \ge p_n$. We define $r_1 := 0$ and $r_i = \sum_{j=1}^{i-1} p_j$ for $i \ge 2$. Furthermore, we choose natural numbers $m_1,\ldots,m_n$ such that $$2^{-m_i} \le p_i < 2^{-m_i+1}.$$
Now, we take a look at the binary notation
$$r_i = 0,b_{i_1}b_{i_2}\ldots$$
for $i = 1,\ldots,n$. Now, $a_i$ shall possess the code word $b_{i_1}b_{i_2}\ldots b_{i_{m_i}}.$ Show that this code can be decoded uniqely.
I know that a code can be decoded uniquely iff no code word possesses another code word as a prefix. But I still seem to lack the understanding of what exactly $r_i = 0,b_{i_1}b_{i_2}...$ is because I made up a counter-example that can't be valid. Say $a_1$, $a_2$ and $a_3$ are my symbols with probability $p_1 = 1/6$, $p_2 = 1/6$ and $p_3 = 1/6$. Then, $m_1 = m_2 = m_3 = 3$ and $r_1 = 0$, $r_2 = 1/6$ and $r_3 = 1/3$.
Now I have to write $r_2$ and $r_3$ in binary notation. I think it looks like this: $r_2 = 0.110$ and $r_3 = 0.11$, but this leads to one code word being a prefix of the other. Plus, $r_3$ has to be of length $3$ actually, but I don't see how to complete it.
Another example, since the first one doesn't seem to make sense:
$r_1 = 0, r_2 = 1/2$ and $r_3 = 7/12$ for $p_1 = 1/2$ and $p_2 = 1/12$. Then $a_1$ is encoded by $0$, $a_2$ is encoded by $1$ and $a_3$ is encoded by $1001$.