sexta-feira, 13 de março de 2015

Given two algorithms A and B to solve a problem. Given a input of size N  \mathbb{N}
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