实施例0-1的(N!)? [英] Example of O(n!)?

查看:125
本文介绍了实施例0-1的(N!)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是一个例子(在code)一O(N!)的功能?应采取行动,以参考运行至n的适当数量;也就是说,我问时间复杂度。

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 about time complexity.

推荐答案

你去那里。这可能是在运行Ø功能的最简单的例子(N!)时间(其中 N 是函数参数):

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<n; i++) {
    nFacRuntimeFunc(n-1);
  }
}

这篇关于实施例0-1的(N!)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆