prove that minimal number of comparisons to find median among five elements is 5
Your proof is correct. But I don't think 5 comparisons is achievable.
Here is the algorithm that finds the median in 6 comparisons.


Sort the first two pairs. [ 2 comparisons]
Order the pairs w.r.t. their respective larger element. [ 1 comparison]

Call the result $[a,b,c,d,e]$; we know $a&lt;b&lt;d$ and $c&lt;d$.
Now there are 3 elements less than $d$, hence $d$ can't be the median( i.e. $3^{rd}$element of the sorted array)
WLOG say $c&lt;e$ and $a&lt;b$ (known already). Order the pairs w.r.t. their respective larger element. WLOG $a&lt;b&lt;e$ and $c&lt;e$. Compare $c$ &amp; $b$, greater one is the median.
[ 3 comparisons - 1 for $c$ &amp; $e$, 1 for ordering the pairs and  1 for $b$ &amp; $c$ ]


Hence, total number of comparisons is equal to 6.

Idea taken from here .