Decreased memory use of weighted median