Define $f:(0,1]\to\mathbb{R}$ by $$f(x):=\begin{cases} \frac{2x}{\theta}, \;\;\;\;\;\;\;\;\text{when}\,\,\,0<x\leq\theta \\ \frac{2(1-x)}{1-\theta},\;\;\;\text{when}\;\theta<x\leq 1 \end{cases}.$$
I need to write a pseudocode for an algorithm that computes the MLE for $\theta$. I am searching the internet, but couldn't find a clear description of such algorithm.