Slowest Computational Complexity (Big-O)

こ雲淡風輕ζ 提交于 2019-12-05 02:59:51

问题


Out of these algorithms, I know Alg1 is the fastest, since it is n squared. Next would be Alg4 since it is n cubed, and then Alg2 is probably the slowest since it is 2^n (which is supposed to have a very poor performance).

However Alg3 and Alg5 are something I have yet to come across in my reading in terms of speed. How do these two algorithms rank up to the other 3 in terms of which is faster and slower? Thanks for any help.

Edit: Now that I think about it, is Alg3 referring to O(n log n)? If the ln inside of it means 'log', then that would make it the fastest.


回答1:


The ascending order would be: n·log(n) < n2 < n3 < 2n < n! for n ≥ 10.

Also have a look at the Big-O Algorithm Complexity Cheat Sheet.



来源:https://stackoverflow.com/questions/16388759/slowest-computational-complexity-big-o

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!