Big-O Notation regarding logarithms

后端 未结 4 492
离开以前
离开以前 2021-01-06 10:22

I got asked an interview question that wanted me to discern the Big-O notation of several logarithmic functions. The functions were as follows:

f(x) = log5

4条回答
  •  情歌与酒
    2021-01-06 10:30

    This is a matter of math:

    1. f(x) = log5(x)
    2. f(x) = log(x5) = 5 * log x
    3. f(x) = log(6*log x) = log 6 + log(log x)
    4. f(x) = log(log x)

    So the Big O is

    1. O(log5(x))
    2. O(log x)
    3. O(log (log x))
    4. O(log (log x))

    So (1) and (2) aren't equivalent, but (3) and (4) are (though they're different from both (1) and (2))

提交回复
热议问题