问题
I've just started working with algorithms and I am doing some tasks like this question:
I think, the right answer is A. As the functions are the same, or do I miss something?
Question:
回答1:
The answer is A. Notice that in that case,
f(N) = N + 2N + 3N = 6N = g(N)
so f(N) ~ g(N).
For the functions given in B, notice that
f(N) = (N + 1) + (N + 2) + (N + 3) = 3N + 6
so the limit of f(N) / g(N) as N tends toward infinity is 3, and therefore f(N) is not tilde of g(N).
For the functions in C, notice that
f(N) / g(N) = 1 / N5 + 1 / N4 + 1 / N3
and, in the limit, this does not tend to one.
For the functions in D, notice that
f(N) = log N + log 2N + log 3N = log 6N3 = 3 log 6N
so the limit of f(N) over g(N) as N tends toward infinity is 3, so the functions aren't tilde of one another.
回答2:
Yes, A is the correct answer.
Tilde here means an (approximate, not precise) equivalence relation. Or in other words, the limit of f(N) / g(N) as N approaches infinity = 1.
In answer A, f and g are obviously equivalent, so the limit is 1. This doesn't hold for the other three answers, which have limits 3, 0, and 3 respectively.
来源:https://stackoverflow.com/questions/36463202/which-pair-of-functions-satisfy-f-n-gn