作者elfkiller (没有昵称)
看板Grad-ProbAsk
标题Re: [问题] 资结请教?
时间Sat Mar 21 21:31:53 2009
※ 引述《christensen ()》之铭言:
: 1. write out the recursive and the non-recursive pseudo-codes for computing
: n
: the binomial coefficient n as defined in follows: C m = n!/m!(n-m)!
: C m
recursive C(n,m) :
begin
if(m = 0) return 1
else return C(n-1,m-1)+C(n-1,m)
end
non-recursive C(n,m) :
begin
x <- 1
y <- 1
z <- 1
for i <- 1 to n
x <- x*i
for i <- 1 to m
y <- y*i
for i <- 1 to n-m
z <- z*i
return x/y*z
end
: 2. 给定n个正整数。在这n个正整数中找到两个相异数x,y,使得(x+y)(x-y)有最大值,
: 请问这个问题存在O(n)的演算法吗?如果有,请说明你的演算法;
: 如果没有,请说明你的理由
i.e max{x^2-y^2}
找出最大和最小数只须O(n)
: 3. please analyze the time complexity of the following program segment.
: for(I=0; I< n; I++)
: {
: J=1;
: While (J>=2)
: J=J/2;
: }
: 4.there is a float array A[18][10] (size of (float)=4). If the address of
: A[11][2] is 10E9 . What is the address of A[15][13]?
: (16)
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 220.139.147.201
※ 编辑: elfkiller 来自: 220.139.147.201 (03/21 21:42)
1F:推 christensen:感谢大大! 03/22 01:18