Professional Documents
Culture Documents
2. There is a part of program. Please compute its time complexity θ(n) and prove it.(20%)
i=1;
sum=0;
while (i<=n)
{
sum = sum+i;
i=i×2;
}
0 3 0 0 0
0 0 0 0 3
3. G 0 0 2 0 0 , use a two-dimensional array to represent sparse(稀疏) matrix G & GT .(20%)
1 0 0 0 2
0 0 1 0 0
4. Use array to represent the following function?(Avoid wasting space as much as you can)(20%)
(a) f(x)=3x2+2x+4
(b)g(x)=x3+1
(c) f(x)+g(x)
(d)f(x)*g(x)
5. Show each state of the list (1, 6, 8, 13, 19, 22, 27) for (a) and (b) by using binary search:(20%)
(a) search 19
(b) search 7