[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 16—Search Problems 1

Before Lecture

There is no pre-lecture work for this lecture. It will be a fun and challenging lecture, so please show up with bells on.

During Lecture

The starters for this lecture are:

After Lecture

Today's program had everything. Representing information, generative search, template blending, simple templating, using built-in abstract list functions. Pretty much everything we've done. It was also a great example of how what we have learned breaks big problems into a lot of much smaller problems. As just one example, when we are coding valid-next-positions, and we realize "ok, some of the positions are valid and I want to do just those, then using what we know about templating we can very quickly write this:

(@template-origin use-abstract-fn)      

(define (next-valid-positions p)
  (filter valid? (list ...)))

Then we create the wish list entry for valid? and then go on to complete the design of valid?.

The big idea today was the remarkable insight that we can solve a problem like finding our way through a maze by generating a tree of possible routes and searching that tree for a solution. It's not a tree that existed when we started, it is a tree we generate as we go — thus it is a generative recursion.

A key step of the design was to form a template that blends:

Which set us up for doing a backtracking search over a generated arbitrary-arity tree.

Once we had our solve function in place, all that was left to do was HTDF to complete the wishlist entries.

To review today's material we recommend you rework the key steps of the problem:

You can also review this material by working slowly through the Sudoku videos on edX (all of them). They are long, but that is because they develop the example in full. Doing this will be another excellent practice for long problems, which you want to get as much practice as you can with at this point in the term.

The solution for this lecture is:

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