Teaching Programming Without a Net

This morning I did something I had never done before: I wrote a program in front of an audience.

I had assigned my introduction to programming students the Sieve of Eratosthenes as a problem. I had already written a sieve  in Visual Basic based on Stepanov and Rose's guidelines. But I wanted my students to implement a much simpler version -- they are beginners, after all!

Today, for the first time, I came to class, quite deliberately, without having written the program I was going to show them in advance. I told them, "I want to show you how a programmer thinks through a problem like this."

And I programmed the whole algorithm live, describing each step, and using the Visual Studio debugger to examine what was going on. It was a bit nerve wracking: what if I froze up, and couldn't think of what to do next?

But we got through it, and the students loved it. I will be doing this again.

PS: Having gotten them through the sieve, I need one more algorithm for them to code before I assign them their independent project. Any suggestions?


  1. Here is one: nearest neighbor search. Have them write a program that accepts pairs of numbers representing coordinates for input and returns the pairs in an order representing the shortest path connecting all of them. Since the algorithm's output is affected by the choice of the starting point, also have their program test get the result for each possible starting point and return the shortest route out of those.

  2. One I remember finding challenging and enjoyable in high school was the "knight's tour."

    For something more practical maybe the traveling salesman problem or just the shortest path problem.

  3. This comment has been removed by the author.

  4. If Andy's fun suggestions are too sophisticated, they could perhaps start with a basic interview problem:

    - Find the top two maximum values in a list/array of numbers.
    - Reverse each word in a string.
    - Given a collection of 2D coordinates (or equivalently, a 2D array of ones and zeros), find the longest line that can be drawn between two of the points.
    - Or maybe the longest parabola between three points for those that have taken calculus. But that is probably too mean.

  5. They tend to be mathy (but, then again, so is the Sieve of Eratosthenes), but the Project Euler problems are pretty good.


Post a Comment

Popular posts from this blog

Central Planning Works!