資料結構›Ch1 演算法基礎
第 57 題/共 57 題
◀ DS 57/57
57. Recurrence、Master Theorem、Time Complexity
#DS-01-057中RecurrenceMaster TheoremTime Complexity

Consider a general recursive mechanism RR, whose input is an array A() initially with nn elements. The pseudo code of RR is listed below. It takes a parameter kk, use n\sqrt{n} (nn is the size of A when applied, nn may change) steps to partition A, and may call another function QQ, whose complexity may vary and depends on the size of its input.

Procedure R (array A with size n, int k)
1. if n<k exit;
2. partition A into k equal size parts
   A1, A2, ..., Ak (This takes sqrt(n) steps)
3. for (i=1 to k)
   . call R(Ak, k); // may change Ak
4. merge A1, A2, ..., Ak into new A with size n;
   (This takes k steps)
5. call Q(A);
6. return()

There are 3 derived algorithms X, Y, Z, based on RR. X sets kk as 2, and its Q's complexity is θ(m)\theta(m), mm is the size of Q's input. Y sets kk as 4, and its Q's complexity is θ(m)\theta(\sqrt{m}), mm is input size. Z sets kk as 9, and its Q's complexity is θ(m)\theta(m), mm is input size.

What following comparisons are true?

📄 中央111
跳轉到第題
▤完整推導請見《WH 資工筆記 · 資料結構》Ch1 演算法基礎
本章題號 · 41–57 / 57