作者irene6524 (Irene)
看板CSSE
标题[问题] 几个程式的问题
时间Sat Jul 13 00:28:09 2013
安安,各位大大,想请问2题程式
1. What is the time complexity of T(n) defined below? Please justify your answer.
T(1) = 0
T(n) = 2T(n/2) + n n > 1.
这题应该怎麽做???
2.#define M(a,b) a*b
int main(void)
{
int i = 5, j = 6;
printf(”i*j = %d”, M(i+1, j-2*2));
return 0;
}
这题答案为什麽是7呢? 为什麽不是12呢?
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 121.254.127.79
1F:推 suhorng:第二题 i+1*j-2*2 => 5+1*6-2*2 先乘除後加减 => 7 07/13 00:39
2F:→ irene6524:恩恩,了解,感恩。 07/13 00:47
3F:推 devastate:第一题今天我刚在itunesU课程听到,是merge sort的分析 07/16 12:45
4F:→ mihs3124:Problem 1 is buggy. If n is odd, what's n/2? x.5? 10/20 12:21
5F:→ mihs3124:for T(n), n \in 2^x, where X \in normal, 10/20 12:26
6F:→ mihs3124: T(n) = \theta (log_2 n) x n 10/20 12:28
7F:→ mihs3124:For proof, u could use Math Induction. 10/20 12:31