Intro to
Programming
with Python

Fall 2011
course
navigation

nov 22

finish talking about recursion

1. Discuss homework problems
2. Browse a few more examples of recursion

discuss other ideas from chap 13 ("on to computer science")

Once you have the basics of "how to write a program", then what?
The analogy is writing: once you know how to put together a subject, verb, and object, you can write a sentence. But the content of what you can write about is a much bigger topic.
Likewise, "computer science" as a field is about how to best represent and implement various information-related tasks. The recipes for doing these sorts of things are called "algorithms", and so the next step is often to look at them.
For example, given a collection of numbers, how do we find if something specific is in there?
First: try as a class exercise. How many different algorithms can you suggest? How can we measure how good they are?
Linear search is O(n); binary search is O(log(N)). Define these terms and give specific examples.
There are many other tricks besides recursion, for example wikipedia: memoization (particularly helpful for the fibonacci program, for example) and wikipedia: hash functions.
Depending on time, we can also discuss approaches to sorting ; see wikipedia: sorting and http://www.sorting-algorithms.com

I've attached the programs we dicsussed in class.
http://cs.marlboro.edu/ courses/ fall2011/python/ notes/ nov_22
last modified Tuesday November 22 2011 1:00 pm EST

attachments [paper clip]

     name last modified size
   biggest.py Nov 22 2011 12:59 pm 562B    graphics.py Nov 22 2011 12:59 pm 27.7kB    hanoi.py Nov 22 2011 12:59 pm 1.64kB    koch.py Nov 22 2011 12:59 pm 2.63kB    palindrome.py Nov 22 2011 12:59 pm 1.22kB    pegs.py Nov 22 2011 12:59 pm 14.6kB