User:Zelhar/Algorithms0 maman12

4.1
for weights $$w_i=n^{-1}$$ and $$k:=\left \lfloor \frac{n+1}{2} \right \rfloor$$ we have: $$ \sum_{x_i < x_k}{w_i}= \sum_{i=1}^{k-1} {\frac{1}{n}} \le \frac{1}{n}(\left \lfloor \frac{n+1}{2} \right \rfloor -1) \le \frac{1}{n}(\frac{n-1}{2}-1)= \frac{1}{n}(\frac{n-1}{2})<\frac{1}{2} $$ and:  $$\sum_{x_i>x_k}{w_i} = \sum_{i=k+1}^{n}\frac{1}{n}=\frac{1}{n}(n-k)\le\frac{1}{n}(n-\frac{n}{2}) \le\frac{1}{2}\ $$ so $$x_k$$ is the weighted median of $$x_1 \ldots x_n$$