
The algorithm A takes time f(N)=N².
The algorithm B takes g(N)=aN, where a is a constant, for any size of N.
We can conclude that:
a) The A algorithm will always be faster than B because A is quadratic, regardless the size of N.
b) The B algorithm will always be faster than A because B is linear, regardless the size of N.
c) When the size of N is smaller than a, the quadratic algorithm will be faster.
d) When the size of N is larger than a, the quadratic algorithm will be faster.
e) NOTA
Original idea by Rodrigo Ritter.
Nenhum comentário:
Postar um comentário