資料結構›Ch1 演算法基礎
第 55 題/共 57 題
◀ DS 55/57
55. Recurrence、Time Complexity
#DS-01-055易RecurrenceTime Complexity
題組題幹(本題:7,共 2 小題)點擊展開

To analyze the complexity of the following procedure P, we will use the following assumptions: Suppose P and B are both procedures. B takes θ(m)\theta(\sqrt{m}) time to compute, where mm is the size of B's input; each statement line in and outside the loop counts 1 step.

Procedure P(array1[a1, a2, ..., an])
1. if n<9 exit.
2. call B(array1[a1, a2, ..., an])
   declare new empty array2, array3, array4;
3. for (i=1 to n)
4. { if ((i mod 9)=0)   insert ai into array2;
5.   if ((i mod 9)=3)   insert ai into array3;
6.   if ((i mod 9)=6)   insert ai into array4 }
8. call P( array2 );
9. call P( array3 );
10. call P (array4);

Which of the following relations on FnF_n can describe the complexity of procedure P with respect to problem size nn?

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