Example of O(n!)?

后端 未结 16 2440
渐次进展
渐次进展 2020-11-30 22:20

What is an example (in code) of a O(n!) function? It should take appropriate number of operations to run in reference to n; that is, I\'m asking a

16条回答
  •  孤城傲影
    2020-11-30 22:41

    There you go. This is probably the most trivial example of a function that runs in O(n!) time (where n is the argument to the function):

    void nFacRuntimeFunc(int n) {
      for(int i=0; i

提交回复
热议问题