SUNY Geneseo Department of Computer Science
{Date}
CSci 141, Fall 2004
Prof. Doug Baldwin
Hand out Lab 2
Beware of pseudocode vs Java in lectures
Mini-assignments: be prepared to answer or ask questions when you come to class
Sections 4.1 - 4.7
How to design experiments
Use experiments to compare theory to reality
Designing experiment
Choose data analysis before starting experiment
Draw conclusion about whether experiment supported hypothesis, based on analysis
Controls and comparison to bio
(Mini-assignment)
Recall the algorithm to draw a line n tiles long
// In some subclass of Robot:
drawLine( int n, Color c ) {
for ( i = 0; i < n; i++ ) {
this.paint( c )
this.move()
}
}
We determined that this sends 2n robot messages to draw a line n tiles long
So actual implementations should run in time proportional to n, i.e., running times should be of the form
for some constant c
Do an experiment to test this idea
n | Time | Const |
---|---|---|
3 | 1.5 | 0.5 |
6 | 3.033 | 0.51 |
12 | 6.237 | 0.52 |
Logic and conditional statements
Read Sections 5.1 - 5.3