I stumbled upon this problem and I'm having hard time understanding the solution , mainly the part about the supremum of the function.
Study the uniform convergence of the following sequence of functions on the interval [$0,1$].
$$f_n(x)= \begin{cases} n^2x, & \text{$0\le x\le \frac{1}{n}$}\\ n^2(\frac{2}{n}-x), & \text{$\frac{1}{n}< x< \frac{2}{n}$}\\ 0, & \text{$\frac{2}{n} \le x \le 1$} \end{cases}$$
The solution :
If $x=0$ then $f_n(x)=0$. This is obvious Let $x\neq0$. Then there exists $n_0 \in N$ such that $\frac{2}{n_0}<x$ and for every $n\ge n_0,\ f_n(x)=0$
Why do we only look at the case $x=0$ and $x>\frac{2}{n}$. What about $\frac{1}{n}<x<\frac{2}{n}$?
So $f_n(x)$ converges pointwise to $f(x)=0$.
Now we need to find $\sup \left \lvert{f_n(x)-f(x)}\right \rvert=\sup > f_n(x)\ge f_n(\frac{1}{n})=n \rightarrow \infty$
The last part is the one I'm at most confused about.
Similarly what is the supremum of the following sequence of functions?
$$f_n(x)= \begin{cases} nx, & \text{$0\le x\le \frac{1}{n}$} \\ 2-nx, & \text{$\frac{1}{n}<x<\frac{2}{n}$}\\ 0, & \text{$\frac{2}{n}\le x\le3$} \end{cases}$$
You have $\frac{1}{n}<x<\frac{2}{n}$ for only a finite number of $n$ so it does not matter when $n \to \infty$.
At this point we have:
It remains to show that $f_n$ does not converge to $0$ i.e that: $$\|f_n-0\|\_\infty \not \to0$$ as $$\sup_{x} |f_n(x)-0| \geq \left|f \left( \frac{1}{n} \right)-0\right| = n$$ you can conclude that $f_n \not \to 0$ and so $f_n$ does not converge uniformly to any function.
For the second example similarly you can show that $f_n$ converge pointwise to $0$ but that: $$\sup |f_n-0| \geq 1$$ so the sequence does not converge uniformly.
Edit
(If you want to find the supremum of such function the first thing is to plot the functions. You can then observe see it is a moving triangle with base $(0/n,2/n)$ and height $n$.)
To show that the supremum is $n$ for the first case you can show both points: