Algorithms for sorted data