Algorithms

Spring 2013
course
navigation

Jan 31

Homework: comments up for first (fibonnaci generally fine; plotting will take some practice); 2nd (several parts - plan accordingly) is posted.
Aside: Dijkstra's Parable of Trains and Toilets

run time practicalities

How many steps is practical for a program that runs in a few minutes? Demonstrate explicitly. Answer : about 1e8 .
What does this imply about the size N of a manageable problem for an algorithm that is

a numerical experiment

As a class exercise

after class clarification

Attached is the code we wrote in class. We didn't finish the numerical experiment, so do *not* expect this code to work ... it hasn't been debugged. But after being finished, it would be something you could use to generate a data.csv :
$ python insertion.py > data.csv
You could also choose to average the results from one size, so rather than output (say)
n, steps 4, 10 4, 12
you'd output one line with "4, 11", where 11 is the average for n=4.
Either way, you then read into R, and generate a plot that you hope will look linear. Since this is a O(n**2) algorithm, n vs sqrt(steps) should be linear. Making that plot in R would be
$ R > data = read.csv("data.csv") > plot(data$n, sqrt(data$steps))
Feel free to email me with questions if any of this doesn't make sense.
http://cs.marlboro.edu/ courses/ spring2013/algorithms/ notes/ Jan_31
last modified Thursday January 31 2013 11:18 am EST

attachments [paper clip]

     name last modified size
   insertion.py Jan 31 2013 11:18 am 1.29kB    steps.py Jan 31 2013 11:17 am 365B