Added a generator-based O(MN) implementation of max-deviation