A probabilistic analysis of a greedy algorithm arising from computational biology