資料結構›Ch1 演算法基礎第 56 題/共 57 題
56. Master Theorem、Big-O
#DS-01-056中Master TheoremBig-O
題組題幹(本題:8,共 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 time to compute, where 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);
What can be the time complexity level of the procedure P in question 7?
📄 中央112
▤完整推導請見《WH 資工筆記 · 資料結構》Ch1 演算法基礎