- Watch Recursion
- Fork this gist
- Answer the following questions in your fork
-
Do you pronounce 'babel' in the same way? Nope
- Follow Up Question: Will you now? Nope
-
What is an example of why/where you might use recursion
An example of where you might use recursion is in a linked list. When you want to find something in a list or find the tail, you would want to do this recursively. A node in a linked list should have no knowledge of the rest of the list, apart from its next node. Looping over a list would be taking the whole list, instead of asking each node if it has what you're looking for. In this example, you would ask the head of the list if it has what you're looking for, and if it doesn't you would call the same function, but on the next node of the head. This would continue until the list returned what you were looking for, or reached the end of the list.
-
-
-
Save toriejw/d54b71ad3ba9a135d5c6 to your computer and use it in GitHub Desktop.
Recursion and Generators Homework
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
👍 Great explanation