We encounter the idea of recursion very often in our daily lives without even knowing it. We have (grand)parents, and after a certain time, we will likely become (grand)parents ourselves. When we press the Delete button to delete a folder on a computer, the operating system checks if the folder contains subfolders and if any subfolder contains its own subfolders. The check is done recursively until every subfolder is detected at the deepest level. In computer science, recursion is an elegant technique to break down a complex problem that has repeated subproblems. The recursive code thus written is concise and intuitive. In this chapter, we will embark on a journey to learn the basics of recursion through a variety of practical examples.

错误:搜索内容不能为空,请输入英文关键词
错误:关键词超出字数限制,请精简
高级检索

Recursion

  • Chenyang Shi

摘要

We encounter the idea of recursion very often in our daily lives without even knowing it. We have (grand)parents, and after a certain time, we will likely become (grand)parents ourselves. When we press the Delete button to delete a folder on a computer, the operating system checks if the folder contains subfolders and if any subfolder contains its own subfolders. The check is done recursively until every subfolder is detected at the deepest level. In computer science, recursion is an elegant technique to break down a complex problem that has repeated subproblems. The recursive code thus written is concise and intuitive. In this chapter, we will embark on a journey to learn the basics of recursion through a variety of practical examples.