渐近预期运行时间(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
相关问答
更多-
我的猜测是你正在使用带有该函数的主题来计算搜索结果,而该方法未定义,因此错误“”无效方法Mage_Catalog_Block_Layer_Filter_Category :: shouldDisplayProductCount “ 尝试默认主题,看看它是否有效。 My guess is that you are using a theme with the function to count the search results while that method is not defined, hence ...
-
import requests import json from bs4 import BeautifulSoup headers = {'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.86 Safari/537.36'} s = requests.get('http://www.google.com/search?q= ...
-
搜索时出错:全部(Error searching for :all)[2022-12-04]
我觉得找不到:全部。 文件说 “使用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 ... -
检查search_fields文档, 如上所述 这些字段应该是某种文本字段,例如CharField或TextField。 您还可以使用查找API“跟随”表示法对ForeignKey或ManyToManyField执行相关查找: search_fields = ['foreign_key__related_fieldname'] 所以在你的情况下 search_fields = ['identity__username'] 另请注意,它并没有说您可以使用先尝试过的计算属性 Check search_fie ...
-
使用Sunspot Solr Rails 3搜索多个模型时出错(Error searching multiple models with Sunspot Solr Rails 3)[2022-10-14]
在进行单一模型搜索时,您将结果呈现在受尊重的控制器的相同索引页中,例如,让我们在gem文档( articles_controller.rb )中使用Article模型。 def index @search = Article.search do fulltext params[:search] with(:published_at).less_than(Time.zone.now) facet(:publish_month) with(:publish_month ... -
搜索(Searching through)[2023-04-21]
i18n-tasks是一个通过静态分析实现这一目标的宝石: i18n-tasks is a gem that does just this with static analysis: -
SQL LIKE%NOT SEARCHING(SQL LIKE % NOT SEARCHING)[2023-04-11]
使用 LIKE '%' + @search + '%' 代替 LIKE '%@search%' 完整查询; ... else { sql = "SELECT a.cname,[bid],b.[bname],b.[baddress],b.[bcity],b.[bstate],b.[bpostcode],b.[bphone],b.[bfax],b.[bemail] FROM [CLIENT] a INNER JOIN [BRANCH] b ON a.clientID=b.clientID WHERE ... -
item不是ElectricSpecifications的属性,而是其子节点,因此不是 [@item='Frequency'] 语法,试试 item[@name='Frequency'] 所以完整的XPath应该是这样的 //product/ElectricSpecifications/item[@name='Frequency' and contains(., ' $value')] item is not an attribute of ElectricSpecifications, but it ...
-
尝试从首选项中删除所有更新站点,重新启动STS,然后逐步添加它们以查看错误何时开始显示。 Try to delete all the update sites from the preferences, restart STS, and add them back, step by step to see when the error starts to appear.
-
根据我的评论,错误发生是因为您的文件路径太长。 正如@Richard评论的那样,您可以直接使用Win32 API来绕过此限制。 但是,我个人更喜欢使用TechNet的Delimon.Win32.IO C#库。 该库取代了System.IO的基本文件功能,并支持最多32,767个字符的文件和文件夹名称。 请参阅下面的基本代码示例: using System; using System.Collections.Generic; using System.Linq; using System.Text; ...