为什么这个简单算法T(n / 2)+1的最坏情况时间复杂度与n ^ 2 + T(n-1)相反?(Why is the worst case time complexity of this simple algorithm T(n/2) +1 as opposed to n^2+T(n-1)?)
以下问题是关于大学最近的任务。 我原以为答案是n ^ 2 + T(n-1)因为我认为n ^ 2会使它的渐近时间复杂度为O(n ^ 2)。 与T(n / 2)+1一样,其渐近时间复杂度为O(log2(n))。
答案被返回,结果是正确的答案是T(n / 2)+1然而我无法理解为什么会这样。
有人可能会向我解释为什么这个算法的最坏情况时间复杂度? 我对时间复杂性的理解可能是错误的。
The following question was on a recent assignment in University. I would have thought the answer would be n^2+T(n-1) as I thought the n^2 would make it's asymptotic time complexity O(n^2). Where as with T(n/2)+1 its asymptotic time complexity would be O(log2(n)).
The answers were returned and it turns out the correct answer is T(n/2)+1 however I can't get my head around why this is the case.
Could someone possibly explain to me why that's the worst case time complexity of this algorithm? It's possible my understanding of time complexity is just wrong.
原文:https://stackoverflow.com/questions/36627715
满意答案
我也使用glmatrix和require.js,最新的版本有require.js支持,对我来说似乎工作正常。
但是我对require.js的使用略有不同,我的模块通常是这样开始的:
define(['lib/glmatrix/gl-matrix'], function(glmatrix) { var myModule = function() {}; // use glmatrix.vec3, etc here return myModule; });
这对你有用吗?
I use glmatrix too with require.js, the most recent version has require.js support and for me it seems to work fine.
I have however I slightly different usage with require.js, my modules usually start like this:
define(['lib/glmatrix/gl-matrix'], function(glmatrix) { var myModule = function() {}; // use glmatrix.vec3, etc here return myModule; });
Does this work for you?
相关问答
更多如何一起使用requireJS和jQuery?(How do I use requireJS and jQuery together?)
使用带有requirejs的whenjs(Using whenjs with requirejs)
RequireJS应用程序无法识别我的依赖项(RequireJS application not recognising my dependencies)
glMatrix不工作?(glMatrix not working?)
RequireJS优化器 - Oracle MapViewer有多个匿名定义(RequireJS optimizer - Oracle MapViewer has more than one anonymous define)
使用requirejs与节点(using requirejs with node)
无法找到gradle 2.2.0-rc1(Could not find gradle 2.2.0-rc1)
使用cordova-android创建,导致cordova-2.2.0.jar:没有这样的文件或目录(use cordova-android create,cause cordova-2.2.0.jar: No such file or directory)
使用RequireJS设置smooch-js(Setup smooch-js with RequireJS)
带有RequireJS的glMatrix 2.2.0(glMatrix 2.2.0 with RequireJS)
相关文章
更多I18n的一个问题
hibernate 1+N 问题
The Log: What every software engineer should know about real-time data's unifying abstraction
Don’t work. Be hated. Love someone.
hibernate一级缓存及N+1问题
物理专业英语词汇(H-N)
Storm常见模式——求TOP N
solr 优化索引成 2段或N段
I18N 国际化 简介
gui求jtapi高手T_T
最新问答
更多sp_updatestats是否导致SQL Server 2005中无法访问表?(Does sp_updatestats cause tables to be inaccessible in SQL Server 2005?)
如何创建一个可以与持续运行的服务交互的CLI,类似于MySQL的shell?(How to create a CLI that can interact with a continuously running service, similar to MySQL's shell?)
AESGCM解密失败的MAC(AESGCM decryption failing with MAC)
Zurb Foundation 4 - 嵌套网格对齐问题(Zurb Foundation 4 - Nested grid alignment issues)
湖北京山哪里有修平板计算机的
SimplePie问题(SimplePie Problem)
在不同的任务中,我们可以同时使用多少“上下文”?(How many 'context' we can use at a time simultaneously in different tasks?)
HTML / Javascript:从子目录启用文件夹访问(HTML/Javascript: Enabling folder access from a subdirectory)
为什么我会收到链接错误?(Why do I get a linker error?)
如何正确定义析构函数(How to properly define destructor)
Copyright ©2023 peixunduo.com All Rights Reserved.粤ICP备14003112号
本站部分内容来源于互联网,仅供学习和参考使用,请莫用于商业用途。如有侵犯你的版权,请联系我们(neng862121861#163.com),本站将尽快处理。谢谢合作!