问两个sicp里的问题
fantasybei
2008-09-27
在sicp的1.2.2 Tree Recursion中讲树形递归的时候有这么句话
引用 In fact, it is not hard to show that the number of times the procedure will compute (fib 1) or (fib 0) (the number of leaves in the above tree, in general) is precisely Fib(n + 1)
讲的是斐波那契数列Fib(n)的叶子节点,或者说计算(fib 1) or (fib 0)的次数是Fib(n + 1)次,这个是怎么算出来的呢? 还有一个是1.2.2中接下去那个Example: Counting change,换零钱问题,他说换法的种数是 引用 The number of ways to change amount a using n kinds of coins equals
这两个之和。看不出来为啥是这两个之和呢?
the number of ways to change amount a using all but the first kind of coin, plus the number of ways to change amount a - d using all n kinds of coins, where d is the denomination of the first kind of coin. 这些好像大多是数学上的问题,不知道读sicp的时候有没有必要把这些都搞清楚呢?谢谢各位指点! |