What are some practical uses of recursion in code? If I can do the same thing a recursive function does in a for loop, why do we still use recursion? What are its benefits?

Once you have some practice working with recursion, it is often easier (and faster, and less bug-prone) to write code recursively. There are some problems where writing a recursive solution is easier, and writing an iterative solution is very challenging and difficult.

How do I remove the limit to recursion?

Remove it entirely? You can't; your computer is a finite resource, so you will always have some upper bound on the depth you can grow the recursive call stack.

There is a way to increase the recursive depth allowed in Python, but this will affect your computer (by slowing it down and limiting the memory that other programs can use), and it is really, really outside the scope of CS21.

When dealing with large quantities, how does one get around overflow limits?

One way is to figure out how to use recursion in a smart way that doesn't add as many stack frames to the stack. If you have truly large inputs, there is no avoiding it: you have to deal with them somehow. Sometimes the best we can do is a for loop, and even that can still run out of memory or take too long.

Why does the input have to be smaller? If we were to make the base case very large and increase the input so that it still approaches the base case is that okay? Is this just a convention or will the recursive function break?

If the base case is large and the recursive function calls make the input size larger, this will still be okay as long as every chain of recursive calls eventually reaches the base case (and is not too long).

How can you tell what the appropriate base case is? / For things more complicated than factorials, how do you know what the base case is supposed to be?

Practice.

Often the problem has one case which obviously does not require recursion, and the function can just return an answer, and that should be the base case. Sometimes it's a matter of personal judgment and coding style. (We could have written the base case of sum to be num == 0, but we chose num == 1 instead.)

How will we be applying recursion to our labs/coding?

The same way we do in class: we'll see problems, and practice writing recursive and iterative solutions to them.

Is it more common to use recursion over accumulators?

I'd say yes, but it depends on the kind of problem you are solving. Many problems lend themselves to easy-to-write recursive solutions and very complicated-to-write iterative solutions.

What other purposes are there for recursive functions besides numeric operations? / Can you use recursion for things that aren't math? / In what other situations can recursions be applied?

Pretty much everywhere. :) We'll see a lot more examples throughout the week!


Recursion is very confusing and I am confused.

This is a completely valid feeling. Recursion is very confusing. We're going to continue practicing it to get the hang of thinking in a recursive way.

Recursion is weird but useful I think.

Yep!