As mentioned, consider ${ x _1, \ldots, x _n }$ i.i.d. sampled using density
$${ f _{\theta} (x) = \frac{1}{4\theta} \mathbb{1}(x \in [0, 2\theta]) + \frac{1}{4\theta} \mathbb{1}(x \in [\theta, 3\theta]). }$$
The goal is to estimate ${ \theta }$ from the sample using expectation-maximization.
We can think of the sample as coming from the random variable ${ U _1 ^Z U _2 ^{1-Z} }$ where ${ Z \sim \text{Unif}\lbrace 0, 1 \rbrace }$ and ${ U _1 \sim \text{Unif}[0, 2\theta] ,}$ ${ U _2 \sim \text{Unif}[\theta, 3\theta] .}$
Had we had access to ${ (z _1, x _1), \ldots, (z _n, x _n) }$ instead of just ${ x _1, \ldots, x _n ,}$ we could have computed the likelihood
$${ \begin{align*} &\quad\ell((z _1, x _1), \ldots, (z _n, x _n) ; \theta) \\ &= \prod _{i=1} ^{n} f _{(Z,X)} (z _i, x _i) \\ &= \prod _{i=1} ^{n} f _{X \vert Z = z _i} (x _i) \mathbb{P}(Z = z _i) \\ &= \frac{1}{2 ^n} \prod _{i=1} ^{n} \left( \frac{1}{2\theta} \mathbb{1}(x _i \in [0, 2\theta]) \right) ^{z _i} \left( \frac{1}{2\theta} \mathbb{1}(x _i \in [\theta, 3\theta]) \right) ^{1-z _i} \end{align*} }$$
and looked at
$${ \hat{\theta} ^{\text{MLE}} = \text{argmax} _{\theta} \ell((z _1, x _1), \ldots, (z _n, x _n) ; \theta) . }$$
Due to not knowing ${ z _i }$s, we instead do the following.
Expectation-Maximization Algorithm:
Initialise ${ {\color{red}{\hat{\theta}}} }$ to some value. Compute approximations ${ {\color{blue}{\hat{z _i}}} \leftarrow \mathbb{E} _{{\color{red}{\hat{\theta}}}} [Z \vert X = x _i], }$ and update ${ \hat{\theta} }$ to value
$${ {\color{red}{\hat{\theta}}} \leftarrow \text{argmax} _{\theta} \ell (({\color{blue}{\hat{z _1}}}, x _1), \ldots, ({\color{blue}{\hat{z _n}}}, x _n); \theta). }$$
Continue so, finding new approximations ${ \hat{z _i} \leftarrow \mathbb{E} _{\hat{\theta}} [Z \vert X = x _i] }$ (called the expectation step) and updating ${ \hat{\theta} }$ as MLE for likelihood ${ \ell ((\hat{z _1}, x _1), \ldots, (\hat{z _n}, x _n); \theta) }$ (called the maximization step).
We are given sample ${ x _1 = 1.01, }$ ${ x _2 = 1.02, }$ ${ x _3 = 1.19 ,}$ ${ x _4 = 1.19 ,}$ ${ x _5 = 1.28, }$ ${ x _6 = 2.39 ,}$ ${ x _7 = 2.56 ,}$ ${ x _8 = 2.58 .}$
First Iteration: Initialise ${ \hat{\theta} \leftarrow 3 .}$ Now approximations
$${ \begin{align*} \hat{z _i} &\leftarrow \mathbb{E} _{\hat{\theta}} [Z \vert X = x _i ] \\ &= \mathbb{P}[Z = 1 \vert X = x _i] \\ &= \frac{f _{X \vert Z = 1} (x _i) \mathbb{P}[Z=1] }{f _X (x _i)} \\ &= \frac{1}{2} \frac{\frac{1}{2\hat{\theta}} \mathbb{1}(x _i \in [0, 2\hat{\theta}]) }{ \frac{1}{4\hat{\theta}} \mathbb{1}(x _i \in [0, 2\hat{\theta}]) + \frac{1}{4\hat{\theta}} \mathbb{1}(x _i \in [\theta, 3\hat{\theta}])} \\ &= \frac{\mathbb{1}(x _i \in [0, 6])}{\mathbb{1}(x _i \in [0, 6]) + \mathbb{1}(x _i \in [3, 9])} \\ &= 1 . \end{align*} }$$
So we update
$${ \begin{align*} \hat{\theta} &\leftarrow \text{argmax} _{\theta} \ell ((\hat{z _1}, x _1), \ldots, (\hat{z _n}, x _n); \theta) \\ &= \text{argmax} _{\theta} \frac{1}{2 ^n} \prod _{i=1} ^{n} \frac{1}{2\theta} \mathbb{1}(x _i \in [0, 2\theta]) \\ &= \text{argmax} _{\theta} \frac{1}{\theta ^8} \mathbb{1}(\text{each } x _i \in [0, 2\theta]) \\ &= \frac{1}{2} \text{max}(x _i) = \frac{1}{2} \times 2.58 = 1.29. \end{align*} }$$
Second Iteration: We begin with ${ \hat{\theta} \leftarrow 1.29 .}$ Now approximations
$${ \begin{align*} \hat{z _i} &\leftarrow \mathbb{E} _{\hat{\theta}} [Z \vert X = x _i ] \\ &= \frac{1}{2} \frac{\frac{1}{2\hat{\theta}} \mathbb{1}(x _i \in [0, 2\hat{\theta}]) }{ \frac{1}{4\hat{\theta}} \mathbb{1}(x _i \in [0, 2\hat{\theta}]) + \frac{1}{4\hat{\theta}} \mathbb{1}(x _i \in [\theta, 3\hat{\theta}])} \\ &= \frac{\mathbb{1}(x _i \in [0, 2.58])}{\mathbb{1}(x _i \in [0, 2.58]) + \mathbb{1}(x _i \in [1.29, 3.87])}. \end{align*} }$$
So the first five ${ \hat{z _i} }$s are ${ 1 }$ and the rest are ${ \frac{1}{2} .}$ So we update
$${ \begin{align*} \hat{\theta} &\leftarrow \text{argmax} _{\theta} \ell ((\hat{z _1}, x _1), \ldots, (\hat{z _n}, x _n); \theta) \\ &= \text{argmax} _{\theta} \prod _{i=1} ^{5} \frac{1}{2\theta} \mathbb{1}(x _i \in [0, 2\theta]) \prod _{i=6} ^{8} \left( \frac{1}{2\theta} \mathbb{1}(x _i \in [0, 2\theta]) \right) ^{\frac{1}{2}} \left( \frac{1}{2\theta} \mathbb{1}(x _i \in [\theta, 3\theta]) \right) ^{\frac{1}{2}} \\ &= \text{argmax} _{\theta} \frac{1}{\theta ^8} \mathbb{1}(\text{each } x _1, \ldots, x _5 \in [0, 2\theta]) \mathbb{1}(\text{each } x _6, x _7, x _8 \in [\theta, 2\theta]) \\ &= 1.29. \end{align*} }$$
Third Iteration: Since we again begin with ${ \hat{\theta} \leftarrow 1.29 ,}$ it is same as the second iteration.