def getMaximum(self, locations, trace=None): """ Finds the location in the current problem with the greatest value. RUNTIME: O(len(locations)) """ (bestLoc, bestVal) = (None, 0) for loc in locations: if bestLoc is None or self.get(loc) > bestVal: (bestLoc, bestVal) = (loc, self.get(loc)) if not trace is None: trace.getMaximum(locations, bestLoc) return bestLoc
def getMaximum(self, locations, trace = None): """ Finds the location in the current problem with the greatest value. RUNTIME: O(len(locations)) """ (bestLoc, bestVal) = (None, 0) for loc in locations: if bestLoc is None or self.get(loc) > bestVal: (bestLoc, bestVal) = (loc, self.get(loc)) if not trace is None: trace.getMaximum(locations, bestLoc) return bestLoc