Check out a free preview of the full Data Structures and Algorithms in JavaScript course:
The "Review: Recursion" Lesson is part of the full, Data Structures and Algorithms in JavaScript course featured in this preview video. Here's what you'd learn in this lesson:

## Recursion is a common technique used throughout many sorting and searching algorithms. Bianca reviews some of the recursion topics covered earlier in the course.

Get Unlimited Access Now

Transcript from the "Review: Recursion" Lesson

[00:00:00]
>> Bianca Gandolfo: Who here didn't quite understand recursion before this class, and then now feels like they have a better understanding? You don't have to just, you don't have to just say that to make me feel good. I just wanna get your insight.
>> Student1: Sure, I definitely have a better understanding of it now.

[00:00:15]
>> Bianca Gandolfo: Cool, what got you there?
>> Student1: I think the practice, the implementing it. It was helpful for me when we talked about visualizing it. I think you talked about a snowball up a hill or something. For me, I picture like sort of a staircase that comes out and you walk back up.

[00:00:43]
>> Bianca Gandolfo: So adding metaphors helped?
>> Student1: Yeah.
>> Bianca Gandolfo: Got it.
>> Student2: I really liked when we walked step by step through the code and you had paced it and keep track. That really I think clicked for me.
>> Student1: Yeah that was key.
>> Bianca Gandolfo: Cool, yeah. So kind of walking through the stack frames and how the code is being executed?

[00:01:04] Cool. Cool, anything else? Anything new, so you probably heard of recursion before and you probably used it before, right? Is there a different way that you used it in this class that you hadn't used it before, that way?
>> Student3: That's the same as the last idea. It was really helpful, tracking just the stack frames, the one you showed us, using the example.

[00:01:39]
>> Bianca Gandolfo: Yeah, so that's kind of changed the way you thought about recursion. Yeah, instead of maybe something magically is happening somewhere. Or there's a lot of visualizations where it has a function side of a function side of a function side of a function. Have you guys seen those?

[00:01:54] Maybe if you research recursion, like Fibonacci N -1, N-2, and it is like a bunch of parentheses? Have you guys looked at that? Who's seen that one?
>> Student1: I think I may have. It's been a long, long time though, ten years ago, maybe.
>> Bianca Gandolfo: Okay, cool. I guess my next question would be, is this more helpful than that?

[00:02:19]
>> Student1: Going through those steps and everything that's, I think, very important.
>> Bianca Gandolfo: Cool.
>> Student4: The part I didn't really get before this class was, I think before when I played around with recursion, the recursive call was always the last thing in the method. Which kinda changes how, or it doesn't change how it works, but it changes what you can do with it.

[00:02:46]
>> Bianca Gandolfo: Yeah.
>> Student4: If you act on it after, it's differently.
>> Bianca Gandolfo: Yeah.
>> Student4: It's different.
>> Bianca Gandolfo: So we learned how the location, this is gonna be important later today, of the recursive call, Matters in terms of execution order. Cool, awesome, yeah, this is really important cuz we're gonna go there later when we start traversing trees in different orders, the recursive calls are important.

[00:03:20] Awesome, was there any exercise that was particularly helpful?
>> Student1: When you walked us through, there was one of them I couldn't figure out on my own. I think it was recursive multiplier or something like that. And then it was you walking us through the solutions to that that helped me.

[00:03:40] I don't remember if it was recursive multiplier or what was the other one? [INAUDIBLE]
>> Bianca Gandolfo: Sort, almost like a reversing an array or something.
>> Student1: Yeah it was multiply, cuz then the reverse was the one after it.
>> Bianca Gandolfo: Got it. Cool. So further study would be tail call optimization which is available in ES6.