CBMS-2017-07
题目来源:Problem 7 日期:2024-07-29 题目主题:CS-算法-时间复杂度分析
解题思路
- 我们需要分别计算 的两种算法的时间复杂度。
- 我们还需要分析两个大整数相乘的递归时间复杂度。
Solution
Part 1: Calculating Polynomial
(A) Individual Calculation of and Summation
First, consider calculating each term individually and then summing them to get .
-
To compute each :
- Computing takes multiplications.
- Therefore, the time to compute is .
-
Summing up the times for all :
Thus, the overall time complexity is .
(B) Using Recurrence to Calculate
The recurrence relation for is:
We calculate in this order:
- Calculating takes .
- Calculating from involves one multiplication and one addition, so it takes .
- Similarly, calculating each from takes .
Since there are such calculations, the overall time complexity is .
Part 2: Multiplying Large Integers
(A) Recursive Multiplication
Given: where:
This involves four multiplications of -bit integers:
(B) Solving the Recursive Equation
The recurrence relation is:
Let . Then we have:
Expanding this, we get:
Since is a constant , we get:
Therefore, in terms of :
(C) Reducing Multiplications
Using the optimized method for :
This involves three multiplications of -bit integers:
Solving this recurrence relation similarly:
Since is a constant , we get:
Therefore, in terms of :
知识点
重点词汇
- polynomial 多项式
- time complexity 时间复杂度
- recurrence relation 递归关系
- multiplication 乘法
参考资料
- Introduction to Algorithms, Cormen et al., Chap. 2 (时间复杂度分析)
- Introduction to Algorithms, Cormen et al., Chap. 30 (多项式和大整数运算)