演算法書也可以寫得很好玩

lt發表於2013-06-02

Algorithms

Copyright c

2006 S. Dasgupta, C. H. Papadimitriou, and U. V. Vazirani

July 18, 2006

第13頁寫道

Let's be a little more concrete about just how bad exponential time is. To compute F200, the fib1 algorithm executes T(200) ≥ F200 ≥ 2138 elementary computer steps. How long this actually takes depends, of course, on the computer used. At this time, the fastest computer in the world is the NEC Earth Simulator, which clocks 40 trillion steps per second. Even on this machine, fib1(200) would take at least 292 seconds. This means that, if we start the computation today, it would still be going long after the sun turns into a red giant star.

But technology is rapidly improvingcomputer speeds have been doubling roughly every 18 months, a phenomenon sometimes called Moore's law. With this extraordinary growth, perhaps fib1 will run a lot faster on next year's machines. Let's seethe running time of fib1(n) is proportional to 20.694n ≈ (1.6)n, so it takes 1.6 times longer to compute Fn+1 than Fn. And under Moore's law, computers get roughly 1.6 times faster each year. So if we can reasonably compute F100 with this year's technology, then next year we will manage F101. And the year after, F102. And so on: just one more Fibonacci number every year! Such is the curse of exponential time.

相關文章