1. The Traveling Salesman problem (TSP) is a famous problem for which there is no known,

tractable solution (though efficient, approximate solutions exist). Given a list of cities and the

distances in between, the task is to find the shortest possible tour (a closed walk in which all

edges are distinct) that visits each city exactly once.

Consider the following algorithm for solving the TSP:

n = number of cities

m = n x n matrix of distances between cities

min = (infinity)

for all possible tours, do:

find the length of the tour

if length

min = length

store tour

a) What is the worst-case (big-O) complexity of this algorithm in terms of n (number of

cities)? You may assume that matrix lookup is O(1), and that the body of the ifstatement

is also O(1). You need not count the if-statement or the for-loop conditional

(i.e., testing to see when the for-loop is done), or any of the initializations at the start of

the algorithm. Clearly show the justification for your answer.

b) Given your complexity analysis, assume that the time required for the algorithm to run

when n = 10 is 1 second. Calculate the time required for n = 20 and show your work.

2. Suppose an algorithm solves a problem of size x in at most the number of steps listed in each

question below. Calculate the asymptotic time complexity (big-T or big-theta) for each example

below. Show your work, including values for c and x0along the way.

a) T(x) = 1

b) T(x) = 5x – 2

c) T(x) =3x^3+ 2 + x2

d) T(x) = log (x * 2x!)