Comparison Re: 组合的枚举算法?# Programming - 葵花宝典
P*t
1 楼
I think proof is better than arguing. So I changed tjq's program a little bit
to do a comparison:
Here is the result: with M=11, N=30, compiling with VC 6, SP5,
With optimization as Max speed,
==================
recursive
Time 1952
non-recursive
Time 1503
Count 54627300
recursive is 450 ms slower than non-recursive. But this is in when we almost
did nothing with the result (in the function "output", uncomment the return).
If I just do a sum over all data in output, the result is:
===============
to do a comparison:
Here is the result: with M=11, N=30, compiling with VC 6, SP5,
With optimization as Max speed,
==================
recursive
Time 1952
non-recursive
Time 1503
Count 54627300
recursive is 450 ms slower than non-recursive. But this is in when we almost
did nothing with the result (in the function "output", uncomment the return).
If I just do a sum over all data in output, the result is:
===============