我努力在O表示法中定义以下算法的运行时间。我的第一个猜测是O(n),但迭代和我应用的数字之间的差距并不稳定。我怎么错误地定义了这个? public int function (int n)
{
if (n == 0) {
return 0;
}
int i = 1;
int j = n ;
while (i < j)
{
我将如何继续证明这两个函数的输入是否正确?我对这个问题有点失落。 let rec reduce f lst u =
match lst with
| [] -> u
| (h::t) -> f h (reduce f t u)
let rec forall2 p l1 l2 =
match (l1,l2) with
| ([],[]) -> t