FAQ: Recursion: Conceptual - Recursion Outline

This community-built FAQ covers the “Recursion Outline” exercise from the lesson “Recursion: Conceptual”.

Paths and Courses
This exercise can be found in the following Codecademy content:

Learn Recursion: Python

FAQs on the exercise Recursion Outline

There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply (reply) below.

If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.

Join the Discussion. Help a fellow learner on their journey.

Ask or answer a question about this exercise by clicking reply (reply) below!

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head here.

Looking for motivation to keep learning? Join our wider discussions.

Learn more about how to use this guide.

Found a bug? Report it!

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!

Have I missed anything in my attempt to answer the questions at the end of this lesson?

Where do the recursive and iterative approaches differ? What parts are similar?

Similarities

  1. will continue to print a single letter whilst there is a letter to print
  2. prints ‘all done’ when there are no more letters to print

Differences

  1. for loop does not need to ‘ask’ for the result of a shorter version of name before it can print, whereas recursion does
  2. recursion cannot begin printing until it gets the result of the base case

How is it possible for a function to resolve if it refers to itself?

Eventually the function will trigger the base case and from there, can resolve each previous function call.

Hmmm I don’t know why this hasn’t been covered yet…

I’m hoping this gets covered in the friendly way everything else normally does but the Time Complexity… I assume its a chapter in “passing the technical” because I’m sure someone will hand out the question how long does your solution take or how long using xyz method take normally…

I think the only thing that I would add to this discussion is that a recursive v. iterative solutions have different time complexities. Recursion takes longer because your calling the function itself so the larger the size the longer the time. But I wonder for iterations… your loop could go on and on too. But I assume repetitive function calls in a recursive solution take much more time than loops cycles. Also the infinite loop problem of recursion vs. just exhausting memory with loops ??

I also view recursion as the self reliance approach aka recursion versus asking lots of questions via loops and iterations? Recursion be like No I got this…somewhere in here it is… And Iterations are like Are We There Yet? No ? Okay How Bout Now? No… What About Now? I don’t know why its got such a cartoonish set up in my mind but it does.

5 Likes

Time Complexity is indeed discussed shortly down the line (which I’m assuming you found out already). Your example for Recursion/Iteration is perfect! :slight_smile:

1 Like

Anyone figured out how to apply recursion to a String. The cheat sheet displays how to implement it onto integers but not sure how to apply it on Strings.

the psuedo code helped a little but my program kept failing. I’m using java but I think I can translate Python well enough to understand how to apply it in Java
image

I’m guessing it would be something like this:

def speller(my_string): if len(my_string) == 0: print("all done") return print(my_string[0]) speller(my_string[1:]) speller("test string")