Are there any real O(n^n) algorithms?

后端 未结 5 717
醉梦人生
醉梦人生 2021-02-01 03:19

Is there any real Algorithm with a time complexity O(n^n), that isn\'t just a gimmick?

I can create such an Algorithm, like computing n^n in O(n^n) / Θ(n^n):

<         


        
相关标签:
5条回答
  • 2021-02-01 03:40

    There are computations (for instance, tetration) where the output size is O(nn). It's kind of hard to compute them with time complexity less than O(nn).

    0 讨论(0)
  • 2021-02-01 03:44

    There are many optimization problems that are essentially O(n!), i.e in data compression. The common algorithms for this all need to cheat one way or another (many rely on heuristics) but can't make sure that they have found the perfect result this way. I.e. choosing the optimal line filters during compression of a PNG image is such a problem that is comparatively easy to understand.

    Another example are algorithms to break encryption which can potentially be even worse than O(n!).

    0 讨论(0)
  • 2021-02-01 03:50

    According to Wikipedia, there are some double exponential time problems O(22poly(n)) which is more complex than O(nn), e.g. "Decision procedures for Presburger arithmetic" (O(22cn)) and "Computing a Gröbner basis" (in worst case O(22n/10)

    0 讨论(0)
  • 2021-02-01 03:50

    The program that takes a description of a (terminating) Turing machine, and returns the number of steps it takes to terminate. This is a relatively simple program to write -- it can simply emulate the Turing machine, and count the steps.

    The complexity of this program has no computable upper bound (and in particular grows faster than any computable function), so certainly grows faster than O(n^n).

    The worst-case run-time on an input of size n is BB(n), the Busy Beaver sequence, which starts 0, 1, 4, 6, 13, is unknown after this (although lower bounds exists -- for example the next two values are at least 47176870 and 7.412×10^36534 respectively) and uncomputable for n large enough.

    0 讨论(0)
  • 2021-02-01 03:53

    What you have coded in your example is very similar to a depth first search. So, that's one answer.

    A depth first search algorithm without any special characteristics ( like re-convergent paths that can be optimized out ), should be n^n.

    This is actually not a contrived example. Chess programs operate on the same algorithm. Each move there are n moves to consider ( i.e. branches ), and you search d moves deep. So that becomes O(n^d)

    0 讨论(0)
提交回复
热议问题