网友您好, 请在下方输入框内输入要搜索的题目:

题目内容 (请给出正确答案)
设有一个递归算法如下intfact(intn){//n大于等于0if(n<=0)return1;elsereturnn*fact(n-1);}则计算fact(n)需要调用该函数的次数为()。

A.n+1

B、n-1

C、n

D、n+2


参考答案

更多 “ 设有一个递归算法如下intfact(intn){//n大于等于0if(n A.n+1B、n-1C、nD、n+2 ” 相关考题
考题 设有一个递归算法如下int fact(intn){//n 大于等于0 if(n<=0)return 1; else return n* fact(n--); }则计算fact(n)需要调用该函数的次数为(30)次。A.nB.n+1C.n+2D.n-1

考题 设有一个递归算法如下 im fact(int n){ if(n<=0)return 1; else return n * fact(n-1); } 下面正确的叙述是(35)。A.计算fact(n)需要执行n次函数调用B.计算fact(n)需要执行n+1次函数调用C.计算fact(n)需要执行n+2次函数调用D.计算fact(n)需要执行n-1次函数调用

考题 设有一个递归算法如下: int fact(int n){ if(n<=0)return 1; else return n*fact(n-1); } 下面正确的叙述是(35)。A.计算fact(n)需要执行n次函数调用B.计算fact(n)需要执行n+1次函数调用C.计算fact(n)需要执行n+2次函数调用D.计算fact(n)需要执行n-1次函数调用

考题 设n的初始值为正整数,设计一个递归算去如下: int fact (int n) { if (n<=0) return l; else return (n*fact (n-l)) ; 以下叙述中正确的是(49) 。A.计算fact(n)需要执行n次函数调用B.计算fact(n)需要执行n+l次函数调用C.计算fact(n)需要执行n+2次函数调用D.计算fact(n)需要执行n-l次函娄[调用

考题 设n的初值为正整数,设计一个递归算法如下:int fact(int n){if(n<=0)return 1;else return(n*fact(n-1));}以下叙述中,正确的是______。A.计算fact(n)需要执行n+2次函数调用 B.计算fact(n)需要执行n+1次函数调用 C.计算fact(n)需要执行n次函数调用 D.计算fact(n)需要执行n-1次函数调用

考题 有如下递归函数fact(n),分析其时间复杂度为()。 int fact(int n) { if(n<=1) return 1; else return(n*fact(n-1)); }A.O(n)B.O(1)C.O(n^2)D.O(logn)

考题 5、设有一个递归算法如下 int fact(int n) { //n大于等于0 if(n<=0) return 1; else return n*fact(n-1); } 则计算fact(n)需要调用该函数的次数为()。A.n-1B.nC.n+1D.n+2

考题 下面的递归函数时间复杂度是O(1) int fact(int n) { if(n<=1)return 1; else return n*fact(n-1); }

考题 7、下面的递归函数时间复杂度是O(1) int fact(int n) { if(n<=1)return 1; else return n*fact(n-1); }

考题 【单选题】设有一个递归算法如下A.int fact(int n) { //n大于等于0B.if(n<=0) return 1;C.else return n*fact(n-1); }D.算fact(n)需要调用该函数的次数为()。E.n+1F.n-1G.nH.n+2