資料結構›Ch1 演算法基礎第 57 題/共 57 題
57. Recurrence、Master Theorem、Time Complexity
#DS-01-057中RecurrenceMaster TheoremTime Complexity
Consider a general recursive mechanism , whose input is an array A() initially with elements. The pseudo code of is listed below. It takes a parameter , use ( is the size of A when applied, may change) steps to partition A, and may call another function , 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 . X sets as 2, and its Q's complexity is , is the size of Q's input. Y sets as 4, and its Q's complexity is , is input size. Z sets as 9, and its Q's complexity is , is input size.
What following comparisons are true?
📄 中央111
▤完整推導請見《WH 資工筆記 · 資料結構》Ch1 演算法基礎