コード例 #1
0
ファイル: peak.py プロジェクト: slingthor/Algorithms
    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
コード例 #2
0
ファイル: peak.py プロジェクト: ZengFan92/OnlineOpenCourses
    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