Calculates minimum and maximum paths in a triangle data