SUNY Geneseo Department of Computer Science


Experimentation

{Date}

CSci 141, Spring 2005
Prof. Doug Baldwin

Return to List of Lectures

Previous Lecture


Questions?

Algorithm Analysis

Mini-assignment: how many Robot messages in Wednesday's fill-a-square algorithm?

    while n > 0
        ...
        n = n -2
    ...
    paintLine(n)
    paintSquare( n )
        for i = n down to 1, decrementing i by 2
            // Block 1
            this.paintLine( n )
            this.turnRight()
            this.move()
            this.turnRight()
            this.move()
            if i > 1
                // Block 2
                this.paintLine( n )
                this.turnLeft()
                this.move()
                this.turnLeft()
                this.move()
            end of if
        end of for

    paintLine
        repeat n times
            this.paint( ...some color... )
            this.move()

First solution

But paintLine takes time proportional to n, so

How about rounding n/2?

Experimentation

Reading Summary: sections 4.1 through 4.7

Verification

Experimentation:

Error

Measuring time

An Experiment

Design and conduct an experiment to test the hypothesis that the running time of a real "paintSquare" method is proportional to the number of Robot messages derived in the mini-assignment

Started with a program that defined an appropriate subclass of Robot, added code to run experiment and collect data.

See the Resulting Program

This was mainly experiment design, including things like devising and inserting instrumentation code, thinking briefly about controlling outside influences by disconnecting from any network and stopping other programs, etc.

But we also noted that we had a hypothesis from the result of the theoretical analysis done at the beginning of class.

Next

Do at least part of the experiment, and then start talking about conditionals.

No reading or mini assignments.


Next Lecture