渐近预期运行时间(Asymptotic Expected Running Time)
我在渐近分析问题上遇到了一些麻烦。 该问题要求渐近最坏情况运行时间和函数的渐近预期运行时间。 Random(n)在1和n之间生成一个均匀分布的随机数(1到n之间的每个整数都是相同的。)
Func2(A, n) /* A is an array of integers */ 1 s ← A[1]; 2 k ← Random(n); 3 if (k < log2(n)) then 4 for i ← 1 to n do 5 j ← 1; 6 while (j < n) do 7 s ← s + A[i] ∗ A[j]; 8 j ← 2 ∗ j; 9 end 10 end 11 end 12 return (s);
我想知道第3行(if(k <log2(n))然后如何影响函数的预期运行时间。 我认为第4-10行在最坏情况下运行cn ^ 2时间,但我不确定如何根据if语句推导出预期的运行时间。 谢谢你的帮助!
-Matt
I'm having some trouble with an asymptotic analysis question. The problem asks for both the asymptotic worst case running time and the asymptotic expected running time of a function. Random(n) generates a random number between 1 and n with uniform distribution (every integer between 1 and n is equally likely.)
Func2(A, n) /* A is an array of integers */ 1 s ← A[1]; 2 k ← Random(n); 3 if (k < log2(n)) then 4 for i ← 1 to n do 5 j ← 1; 6 while (j < n) do 7 s ← s + A[i] ∗ A[j]; 8 j ← 2 ∗ j; 9 end 10 end 11 end 12 return (s);
I was wondering how line 3 (if (k < log2(n)) then) effects the expected running time of the function. I believe lines 4 - 10 run at worst case cn^2 time, but I am unsure how to derive the expected running time due to the if statement. Thanks for any help!
-Matt
原文:https://stackoverflow.com/questions/14689122
满意答案
我觉得找不到:全部。 文件说
“使用find方法,您可以检索与所提供的选项匹配的指定主键对应的对象。我认为这就足够了
Article.where('name LIKE ?', "%#{search}%")
或者如果您找到所有文章
Article.all
I think find can not take :all. the documentation says
"Using the find method, you can retrieve the object corresponding to the specified primary key that matches any supplied options. I think this is enough
Article.where('name LIKE ?', "%#{search}%")
or if you find all the articles
Article.all
相关问答
更多Magento在搜索产品目录搜索时出错(Magento giving error on searching product catalog search)
使用bs4使用Python 3.5搜索Google时出错(Error in searching Google with Python 3.5 using bs4)
搜索时出错:全部(Error searching for :all)
在Django admin中搜索时出错(Error searching in Django admin)
使用Sunspot Solr Rails 3搜索多个模型时出错(Error searching multiple models with Sunspot Solr Rails 3)
搜索(Searching through)
SQL LIKE%NOT SEARCHING(SQL LIKE % NOT SEARCHING)
xpath搜索属性时出错(xpath Error while searching attributes)
更新eclipse时出错:搜索备用解决方案(Error while updating eclipse: Searching Alternate solutions)
directory.getfiles在出错时停止搜索(directory.getfiles stops searching when error)
相关文章
更多HDFS patch前后Ganglia看到running processes变化的分析
Real-Time Rendering 笔记 --- 1-4章
The Log: What every software engineer should know about real-time data's unifying abstraction
Running Solr with Maven
Python IndentationError:expected an indented block的解决方案
Another MySQL daemon already running with the same unix socket.
Hadoop HDFS Wrong FS: hdfs:/ expected file:///
运行时编译执行一段代码
C程序访问Hadoop运行时遇到的各种问题以及解决方案
Hadoop运行时错误:Task process exit with nonzero status of 1
最新问答
更多获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
如何通过引用返回对象?(How is returning an object by reference possible?)
矩阵如何存储在内存中?(How are matrices stored in memory?)
每个请求的Java新会话?(Java New Session For Each Request?)
css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
xcode语法颜色编码解释?(xcode syntax color coding explained?)
在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
Copyright ©2023 peixunduo.com All Rights Reserved.粤ICP备14003112号
本站部分内容来源于互联网,仅供学习和参考使用,请莫用于商业用途。如有侵犯你的版权,请联系我们(neng862121861#163.com),本站将尽快处理。谢谢合作!