chapter 9, recurisve and dynamic programming