From the course: Python: Recursion

Unlock the full course today

Join today to access over 22,500 courses taught by industry experts or purchase this course individually.

The ingredients of a recursive algorithm

The ingredients of a recursive algorithm - Python Tutorial

From the course: Python: Recursion

Start my 1-month free trial

The ingredients of a recursive algorithm

- [Instructor] A recursive algorithm needs to have some basic ingredients in order to work. These can be summarized as the three laws of recursion. So a recursive algorithm must have a base case. And we'll discuss what that is soon. A recursive algorithm must change its state and move towards its base case. And finally a recursive algorithm, must call itself recursively. Let's look at the first two laws. What do we mean by a base case and movement towards it. To explore this, open up your editor, In this case, I'm using pie charm and open up the relevant far for this video, which is wall loop exit conditions.PY in chapter O two O one. Now, if you're using, git to follow along, I'm just going to show you how to work with that. So if you do out F 12, this will open up a terminal. And then if we do git check out and it's going to be O two underscore O one and it's b because we're at the beginning. Okay. And you can see…

Contents