In Class: Week 9
We are going to continue using the same in-class file as we did last
week. To do this, create a week09 subdirectory in your
cs21/class directory, and copy the files from your week08 subdirectory
into your week09 subdirectory:
$ cd
$ cd cs21/class
$ pwd
/home/your_user_name/cs21/class
$ mkdir week09
$ cd week09
$ pwd
/home/your_user_name/cs21/class/week09
$ cp ../week08/list_algs.py .
$ ls
list_algs.py
As always, after class you can copy my in-class code by doing this:
$ cd cs21/class/week09
$ cp ~newhall/public/cs21/week09/tia* .
We are going to do some of the following together:
- Implement a BinarySearch function. We worked on the algorithm
in class on Thursday last week and we will write up a function for
it together.
- Add a function, SelectionSort, to this file. The function
should take a list parameter and sort the list using the selection
sort algorithm.
- Write a program, recursivefact.py, that makes a call to a function,
Factorial, that we will write. Factorial takes a positive int value, n,
and computes the value of n! that it returns. We will implement this
function recursively. Recursive functions are based on recursive
definitions. In this case, n! is equivalent to n * (n-1)!