为什么O(n)优于O(nlog(n))?

编程入门 行业动态 更新时间:2024-10-21 09:36:34
本文介绍了为什么O(n)优于O(nlog(n))?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我只是遇到了这个奇怪的发现,在正常的数学中,n * logn小于n,因为log n通常小于1.那么为什么O(nlog(n))大于O(n)?(即为什么nlogn被认为比n花更多的时间)

Big-O是否采用其他系统?

解决方案

原来,我误解了Logn小于1.当我问几个年长者时,我今天就自己了解了这一点,即如果n的值很大(通常在考虑大O时,即最坏的情况),那么logn可以大于1.

是的,O(1)<O(登录)<O(n)<O(nlogn)成立.

(我以为这是一个愚蠢的问题,也打算将其删除,但是后来意识到,没有问题是愚蠢的问题,可能会有其他人对此感到困惑,所以我把它留在了这里.)

I just came around this weird discovery, in normal maths, n*logn would be lesser than n, because log n is usually less than 1. So why is O(nlog(n)) greater than O(n)? (ie why is nlogn considered to take more time than n)

Does Big-O follow a different system?

解决方案

It turned out, I misunderstood Logn to be lesser than 1. As I asked few of my seniors i got to know this today itself, that if the value of n is large, (which it usually is, when we are considering Big O ie worst case), logn can be greater than 1.

So yeah, O(1) < O(logn) < O(n) < O(nlogn) holds true.

(I thought this to be a dumb question, and was about to delete it as well, but then realised, no question is dumb question and there might be others who get this confusion so I left it here.)

更多推荐

为什么O(n)优于O(nlog(n))?

本文发布于:2023-11-29 16:31:17,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1646951.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:nlog

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!