且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

河内液塔比O(2 ^ n)的更好吗?

更新时间:2023-02-10 15:59:43

由于解决河内塔始终把2 ^ N - 1步......不,你不会找到一个更快的算法,因为它需要O(2 ^ n)的刚打印出的步骤,更不用说计算它们。

Given that solving Towers of Hanoi always takes 2^n - 1 steps...no, you're not going to find a faster algorithm, because it takes O(2^n) just to print out the steps, much less compute them.