SUNY Geneseo Department of Computer Science
{Date}
CSci 141, Fall 2003
Prof. Doug Baldwin
Tomorrow's office hours 2:30 to 3:30, 'cause of a 3:30 meeting.
Timing fast "findLargest"
final int repetitions = 1000;
long start = System.currentTimeMillis();
for ( int i = 0; i < repetitions; i++ ) {
fastArray.findLargest( n );
}
long end = System.currentTimeMillis();
double elapsedTimeForOne =
((double) ( end - start )) / repetitions;
Javaism: integer division truncates
See Chapter 9
Structure (choice and nesting of control, etc.) in individual algorithms helps you design and analyze them
For example
The same is true of data
Definition: A list is...
Basic operations on lists
Maintain a list of things to do
List toDo = new List()
for each task to do today
toDo = new List( task, toDo )
while [ there are still things to do ]
take one out of the list (and do it)
Fill in details of loop as mini-assignment