作者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