Recursion has an intimidating reputation: it’s considered to be an advanced computer science topic frequently brought up in coding interviews. But there’s nothing magical about recursion.
The Recursive Book of Recursion uses Python and JavaScript examples to teach the basics of recursion, exposing the ways that it’s often poorly taught and clarifying the fundamental principles of all recursive algorithms. You’ll learn when to use recursive functions (and, most importantly, when not to use them), how to implement the classic recursive algorithms often brought up in job interviews, and how recursive techniques can help solve countless problems involving tree traversal, combinatorics, and other tricky topics.
This project-based guide contains complete, runnable programs to help you learn:
How recursive functions make use of the call stack, a critical data structure almost never discussed in lessons on recursion
How the head-tail and “leap of faith” techniques can simplify writing recursive functions
How to use recursion to write custom search scripts for your filesystem, draw fractal art, create mazes, and more
How optimization and memoization make recursive algorithms more efficient
Al Sweigart has built a career explaining programming concepts in a fun, approachable manner. If you’ve shied away from learning recursion but want to add this technique to your programming toolkit, or if you’re racing to prepare for your next job interview, this book is for you.
0 有用 唐超旬 2024-09-09 19:38:59 福建
借着看完SICP的劲儿读完了这本通俗讲解递归的书。作者在耐心讲解递归的同时,不厌其烦地批判递归,强调不要使用递归。递归适用于问题化简,树状数据结构,以及带回溯的场景。设计递归的时候要问三个问题:base case是什么?递归传什么参数?递归如何收敛到base case?