Added min/max cost element algorithms.