Save this video free

CS 238 Week 9 Lecture

James Andro-Vasko · 21:09 · Watch on YouTube

Part of University of Nevada, Las Vegas CS 238. See all 12 lectures and search them

These notes were made with YouTube Collector. Paste any YouTube link and get the same: a summary, chapters and a searchable transcript.

Overview

James Andro-Vasko introduces recursion in Python as a function calling itself with a changing parameter until it reaches a base case, then returning results through the call stack. Using factorials and lists, he compares recursive solutions with loops and demonstrates Python’s default recursion limit of 1,000, including how `sys.setrecursionlimit` can raise it.

Key takeaways

Chapters

0:00 Recursion Basics and Iterative Factorial
3:23 Recursive Factorial and the Call Stack
10:23 Recursion Errors and Python’s 1,000-Call Limit
14:15 Recursive List Sum and List Construction

Keep these chapters and the full searchable transcript in your own library.

Transcript excerpt

0:00 Hello CS238 class. Uh this week we're going to be covering uh recursion in I guess this case in Python, but this is really a topic in any programming language. And recursion basically it's like repetition, like doing a loop, but you're using a function that calls itself within itself to emulate that iteration. Now, in this um week's sort of topic, um there's no real use of recursion per se. So, we just kind of cover it just so we get the idea of fundamentals of recursion, but when you go over tree traversals, graph traversals, finding paths in a maze, and backtracking, then it's going

0:49 to involve recursion to be able to um implement this backtracking technique and find alternate paths in a maze or in a graph or in a tree. So, we'll go over the very basics of how recursion works just so we get the idea of recursion, and we'll use simple examples where we won't have to use recursion, but we want to just try to understand the fundamentals of how recursion works. So, for example, let's go ahead and uh look at this uh factorial example uh for our uh lecture on recursion. Okay, let's go ahead and first just define what a factorial is. So, for example, if you have 5 factorial, so we'll be writing it as 5 exclamation point, it's going to be just simply 5 * 4 * 3 * 2 * 1, which is 120. And

1:38 factorials are mostly used um when you go into discrete math and combinations, combinatorial things, you use factorials, and also in some probabilities as well, but for now it's just a very simple uh function like this. Let's define our uh factorial function right here. So, we first have we pass we

This is the start of the transcript. Save this video free for the whole transcript, searchable and time-coded.

In this course

Related notes

Summary, takeaways, and chapters were generated by AI from the video's transcript and may contain errors. The video belongs to its creator, James Andro-Vasko.

Want the full transcript?

Save this video in YouTube Collector to get its complete searchable transcript, your own AI summaries, and a library that keeps every video you collect in one place.