【问题标题】:What is the time complexity for this generic bruteforce/backtracking function?这个通用蛮力/回溯功能的时间复杂度是多少?
【发布时间】:2022-06-16 07:17:21
【问题描述】:

我无法推断其时间复杂度是多少。我正在编写一个回溯函数来解决问题。为简化起见,假设我有一个大小为“a”的列表,并且可以将 0 或 1 放入列表的每个元素中。在尝试了所有组合后,我回来了。这显然是 2^(nm)。

但是,如果在每次递归调用期间我都有固定数量的工作要做呢?我一直在推理这里的复杂性。你能指出我的来源吗?在我的本科学习中,我只记得硕士定理,但这种方法无关紧要。 (我们减去而不是除以得到子问题)

def myfunc(x,a):
    if x == a:
       return
    myfunc2() #Some constant time work
    myfunc(x+1,a)
    myfunc(x+1,a)

【问题讨论】:

  • exp.,,,,,,,,,,,,,

标签: recursion time-complexity complexity-theory backtracking brute-force


猜你喜欢
  • 1970-01-01
  • 2022-01-21
  • 2020-12-03
  • 2015-06-17
  • 2017-09-11
  • 2015-06-12
  • 2021-02-25
  • 1970-01-01
相关资源
最近更新 更多