Last modified: 2019-10-13
This is a course page of
David Casperson
Associate Professor
Computer Science
University of Northern British Columbia

CPSC 200: Algorithm Analysis and Development (2007)

Click to return to the rest of the cpsc 200 information.

Assignment 1 information

This page contains information about assignment one, which is due at the beginning of class 2007-09-27.

The original assignment handed out in class had several minor typos, and one medium-sized one. The corrected assignment can be found below. There should not be any meaningful difference between the original and revised assignments, except that the revised assignment is due this year, rather than last year.

Beware of timing

It is tricky to get your stopwatch to give you more than milli-second precision. Below are some hints on how to do so.

Original Assigment:
Click for the original assignment onehere.
Revised Assignment:
Click for the revised assignment onehere.
About stopwatch functions:

It is tricky to get a good stopwatch function, and the details depend very much on the operating system. On galaxy.unbc.ca the following trick is necessary.

galaxy.unbc.ca

This assumes that you have written a StopWatch that uses gethrvtime function to get times.

When running your program to obtain a running time, run it using ptime. That is, do something like
ptime ./my_program > output.txt
Inside your program use your stopwatch as you normally would, and print out times the way that you normally would. The ptime command is necessary in order to turn on the micro-timers to get accurate times.

Windoze

I don't know how to do high resolution timing on Microsoft platforms. The article linked here seems like it might have code that works, but I don't have a way to test it, or to see what problems it might have.

It does seem like the code given lacks some of the features that I am asking for in my assignment.

Mac OS X

On Mac OS X there is no gethrvtime function, but there is a getrusage function that returns fills a struct with information about the current resource usage of the program. In that resource usage is a struct timeval ru_utime field that keeps track of the elapsed user time.

Home page Semesters Site Map
go back Fall 2007 go forward
2024-12 other links

Fall 2007
Dates
Semester map
CPSC 200
Books
Outline
Old Exams
Policies
CPSC 320
David’s Schedule

fall-2024