Programmatically obtaining Big-O efficiency of code

后端 未结 18 1325

I wonder whether there is any automatic way of determining (at least roughly) the Big-O time complexity of a given function?

If I graphed an O(n) function vs. an O(n

18条回答
  •  长情又很酷
    2020-11-27 16:53

    I think it's pretty much impossible to do this automatically. Remember that O(g(n)) is the worst-case upper bound and many functions perform better than that for a lot of data sets. You'd have to find the worst-case data set for each one in order to compare them. That's a difficult task on its own for many algorithms.

提交回复
热议问题