I'm thinking to do this recursively using the fact the the left subheap is also a min-heap with its root being the minimum using some variation of Select$\left \lfloor \frac{n}{2} \right \rfloor$.
Select-Var($H$,$\left \lfloor \frac{len[H]}{2} \right \rfloor$):
- if $H[1]$ has no children then return it
- if $H[1]$ has only one child return Select-Var($H[2...len[H]]$,$\left \lfloor \frac{len[H]-1}{2} \right \rfloor$)
- if $H[1]$ has two children ...?
How can I complete this algorithm? or is there any better way to do this?
Edit:
The second part of the above algorithm is redundant because the heap is assumed to be full - a full binary tree with $n=2^k-1$ nodes.
I also found that the median can be at any level of the tree except for the root.