Which pair of functions satisfy f (N) ~g(N)?

后端 未结 2 1211
臣服心动
臣服心动 2021-01-28 04:42

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 some

相关标签:
2条回答
  • 2021-01-28 05:40

    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.

    0 讨论(0)
  • 2021-01-28 05:45

    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.

    0 讨论(0)
提交回复
热议问题