Try it on paper first. A hint, the key idea and the worked solution are here when you need them.
For each job, say whether a loop or recursion is the better choice, and why.
Have you tried it?
Work it out on paper first. It is fine to get stuck or make a mistake: that is how we learn. When you are ready, go through the solution one step at a time, and check each step against your own.
Plan. Recursion is clearer for a problem that is made of smaller copies of itself. A loop is better for a simple repeat, and when the depth would be large.
len). Recursion would be too deep for a long text.Check. Ask: does the problem contain a smaller copy of itself? Only the folder does.
Answer: loop, recursion, loop, loop, loop.
Log in to join the discussion.
Loading…
With Standard, you also open 10 more problems, 2 Python labs and 1 extra course. Everything you have used here stays free, always.