You are on page 1of 1

2) This will not compile because there is not a custom comparison operator defined for the Coord class.

The compiler tries to use != in the find() function, but as Coord has not defined the comparison
operators, the compiler has no idea what != should do.
3b) ListAll must have the second parameter (a string) because that string has elements added on to it to
produce the final lines of output. Without the string being recursively passed there would be no way to
correctly produce the output.
4a) The outer loop could potentially loop N times, the middle loop could potentially loop N times, and
the inner loop could potentially loop N times. Therefore, the time complexity is N*N*N or O(N^3).
4b) The time complexity of this algorithm is also O(N^3) because even though the middle loop goes to i, i
has the potential of going all the way to N. N*N*N = O(N^3).
5) The time complexity of this function is O(N^2) because the for loop in the function visits each node
only once, but the function also calls get, which visits each node once as well.

You might also like