[Index of Lectures]

[ L01 L02 L03 L04 L05 L06 L07 L08 L09 L10 L11 L12 L13 L14 L15 L16 L17 L18 L19 L20 L21 L22 L23 ]

Lecture 15—Generative Recursion

Before Lecture

Before lecture, please work through videos in edX module 9a and answer associated online questions.

During Lecture

In this lecture we are going to start working with a new kind of recursion. We have been doing structural recursion, in which each recursive call happens at the natural place where the data was previously built up. But now we are going to start working with generative recursion. In generative recursion, rather than recursive calls receiving a sub-piece of the existing data, the recursive calls receive newly generated data as their argument. This introduces a couple of wrinkles we will need to learn to cope with.

The starters for this lecture are:

After Lecture

qsort was pretty incredible in terms of how many design techniques we have learned were used in the function design:

All of that in one example!

Another thing that the qsort design highlights is how important it is to remember to let the recipe show you what you are ready to do at any one time. This is crucial, if you one step at a time do small parts of the whole design that you are ready to do, then eventually you will actually have solved the whole problem!

This is especially important in something like quicksort that seems initially confusing. Do the examples, that's not so hard. Then you can do the trivial case. Then maybe elaborate an example. And so on.

With regard to the second problem, note that the posted solution is just to the simple cantor function. You can use that to build up the world program if you want. (Good practice!)

As always, a great way to review the lecture is to replay the entire design of quicksort.

At this point you are responsible for all of module 9a. Review the videos, do the practice problem etc.

The solutions for this lecture are:

Be sure to complete the before lecture section of Lecture 16 before that lecture.