HDFS-5673: simplify by allowing algorithms to take longer than O(N).