Algorithm 时间复杂性与空间复杂性
我的算法如下所示。它对服务器进行远程调用并获取处理结果,然后再次将远程调用发送到系统。你能告诉我这个算法的时间和空间复杂度是多少吗Algorithm 时间复杂性与空间复杂性,algorithm,time-complexity,space-complexity,Algorithm,Time Complexity,Space Complexity,我的算法如下所示。它对服务器进行远程调用并获取处理结果,然后再次将远程调用发送到系统。你能告诉我这个算法的时间和空间复杂度是多少吗 Get search keyword from user ϕ := getInfoFromConceptNet(keyword) // makes remote call e := expandConcepts(ϕ) expConcepts := {} // adds to an array for each ec in e // first loop expCon
Get search keyword from user
ϕ := getInfoFromConceptNet(keyword) // makes remote call
e := expandConcepts(ϕ)
expConcepts := {} // adds to an array
for each ec in e // first loop
expConcepts.add(ec) // adds to array
α= expandConcept(ec) //remote call
expConcepts.add(α) // adds to array
αkeywords=getKeywords(α) // calls a function to remove stopwords
for each αkw in αkeywords // second loop
Ω= expandConcept(αkw) // makes remote call
expConcepts.add(Ω) // adds to an array
results[ ]=performsearch(expConcepts,additional information) // searches the array
第二个循环嵌套在第一个循环中?如果是,下面给出的复杂性分析代表您的算法
此算法的时间和空间复杂性取决于
expandConcept()
、getKeywords()
、add()
和performsearch()
函数的实现。对于add()
,如果只是将其参数附加到expConcepts数组前端索引,则时间和空间复杂性可能是O(1)
。假设performsearch()
执行二进制搜索,该搜索具有O(logN)
(N
:expConcepts元素的数量)、时间复杂度和常量空间复杂度,以及额外的O(M*(expandconcepts()时间复杂度)*K*(expandconcepts()时间复杂度))
(M
:集合e的基数,K
:akeywords的基数),你有一个O(M*(expandConcept时间comp)*K*(expandConcept()时间comp)*logN)
时间复杂度。空间复杂度取决于expandConcepts()
空间复杂性。您的第二个循环嵌套在第一个循环中?如果是,下面给出的复杂性分析代表您的算法
该算法的时间和空间复杂度取决于
expandConcept()
、getKeywords()
、add()
和performsearch()
函数的实现。对于add()
,时间和空间复杂度可能是O(1)
if只是将其参数附加到expConcepts数组前端索引。假设performsearch()
执行二进制搜索,该搜索具有O(logN)
(N
:expConcepts元素的数量)、时间复杂度和常量空间复杂度,以及额外的O(M*(expandConcept()time comp)*K*(expandConcept())时间comp)
(M
:集合e的基数,K
:akeywords的基数),你有一个O(M*(expandConcept时间comp)*K*(expandConcept()时间comp)*logN)
时间复杂度。空间复杂度取决于expandConcepts()
空间复杂度。你能正确缩进for循环吗?我甚至不能在你的原始文章中计算缩进。我编辑它只是为了删除额外的空格以便于阅读。你能正确缩进for循环吗?我甚至不能在你的原始文章中计算缩进。我只是编辑它以删除额外的空格以使其更容易阅读更容易阅读。