Algoma University College
Computer Science 2006
Data Structures I
Fall 1996/97
Assignment #1
Pawan Lingras
Date Due: Week 3
Write a template <class type> of a class called timer
which has a member function called time_t time(int n,
type t) that returns the time it took to perform a procedure
called t.work(int n). Make sure that the object
compiles properly by linking with an empty main function and a
test class which has an empty member function called void work(int
n). You will have to include the file time.h.
Assignment #2
Pawan Lingras
Date Due: Week 4
Create three different descendants of timer and time
three procedures consisting of the following code. Your program
should tabulate results for different values of n.
for(int i = 0; i < n; i++)
| for(int i = 0; i < n; i++) | for(int i = 0; i < n; i++)
|
| for(int j = 0; j < n; j++)
| for(int j = 0; j < i;j++) |
sleep(1); | sleep(1);
| sleep(1); |
- You will have to include the file dos.h and create a DOS target
to make sleep function work properly.
- How many times is the instruction sleep(1) executed in each
of these procedures?
- What is the time requirements using big-oh notations for each
of these procedures?
Algoma University College
Computer Science 2006
Data Structures I
Fall 1996/7
Assignment #3
Pawan Lingras
Date Due: Week 5
Horner's rule is a means for evaluating a polynomial:
as:
.
- Implement polynomials as an object containing an array of
objects with two fields exponent and coefficient.
- Write two member functions:
- one which evaluates a polynomial in a straightforward
manner and
- the other using Horner's rule.
- Overload input operator to read a polynomial. You can make
your own assumptions about the input format.
- How many additions and multiplications (as a function of n)
does each of these methods need? Which method is more efficient?
Why?
- Test both the functions for various inputs and submit the
program listing as well as the output.
- Use EasyWin to run the program.
- Bonus: Time both methods using the timer written in
assignment #1. You will have to use multiple inheritance to do
this part.