0

I just want some clarification/reassurance, looking at the code on this GitHub here, would the Big O notation for the time complexity by On2, as it is directly proportional to the amount of vertices/cities in the problem?

AxleCat
  • 57
  • 2
  • 9

1 Answers1

1

The code relies on a distance matrix of cities:

def getDistanceMatrix(cities):
    distanceMatrix = []
    for currentNode in cities:
        subArray = []
        for comparisonNode in cities:
            subArray.append(getDistanceBetweenTwoCities(currentNode, comparisonNode))
        distanceMatrix.append(subArray)
    return distanceMatrix

It is thus of order O(n^2) where n is the number of cities.

Reinhard Männer
  • 14,022
  • 5
  • 54
  • 116