考虑到sin, cos 都是periodic function, 只需要计算x 在0 到2pi 之间的值。所以这个程序是 O(1)的? (for any given step. )
我下面的问题他没理,估计你能答。
所有跟帖:
• 我回答了,你说的部分对,只需要计算0到Pi/4, 不需要到2Pi,最优化是 O(logn) -兄贵- ♂ (0 bytes) () 12/08/2022 postreply 19:53:19
• where does the log n come from? -trivial- ♀ (110 bytes) () 12/08/2022 postreply 19:59:13
• 我的code还是O(n), 但是可以优化到 O(logn),因为不必从0开始一步一步走,而是通过插值。另外因为同时算 -兄贵- ♂ (0 bytes) () 12/08/2022 postreply 20:04:04
• 因为同时算sin和cos,所以每隔 Pi/4, 数值就重复了,可以通过三角函数公式得到其他x的sin值 -兄贵- ♂ (0 bytes) () 12/08/2022 postreply 20:05:42
• 你并没有回答我的问题。我还是等风景吧 -trivial- ♀ (0 bytes) () 12/08/2022 postreply 20:12:31