SC330: A A D S E: Pplied Lgorithms and ATA Tructures For Ngineers
SC330: A A D S E: Pplied Lgorithms and ATA Tructures For Ngineers
1)
10
= 1024
10
X
3.1415
2i
i=0
c) A.1-3 Given
d) Using LHopitals rule to show that (A.5) implies (A.1) see Guillaume de l'Hpital on
Wikipedia of course!
e) A.2-4 Give a lower and upper bound to
using
Show that these bounds hold relative to the exact answer in (A.4)
2) Fill in the following table with T or F for each relation.
f(n)
g(n)
6n + 7
n
f(n) O(g(n))
f(n) (g(n))
f(n) (g(n))
f(n) (g(n))
f(n) (g(n))
average measurement for each N you should generate many random sets of p, q = O(N).
The following code gives long integers for p,q with p => q:
p = ((RAND_MAX+1)*rand() + rand())%N + 1 ;
q = ((RAND_MAX+1)*rand() + rand())%N + 1 ;
if(p < q) {
unsigned long int tmp = p;
p = q;
q = tmp;
};
[d] Try to plot each algorithm on both linear and log plots. Should see that
the DumbGCD is fit well a linear function in T(N) = const*N, whereas the EuclidGCD
is fit well a linear function in log(N), T(N) = const*log(N).
Graphing the output:
You can use any graphic method that you like but a basic one on all UNIX machines is gnuplot.
See instruction at http://www.gnuplot.info/
Submitting Assignment:
All of the results for problem 1 and 2 above and the two figures for problem 3 should be
submitted as pdf file to the blackboard, EXCEPT the program main.cpp.
You should fill in the answers to Problem 1 and 2 directly into the Word document.
Submitting the program:
For the programming problem, a Makefile has been provided for you to be able easily compile
your program during testing/development. Before submitting your program, MAKE SURE that
your code compiles in Linux using the Makefile provided.
- Put your main.cpp into a folder named yourBUid_hw1 and tar (or zip) the folder.
- Email this tar/zip file (yourBUid_hw1.tar) to [email protected] with the EXACT
subject line yourBuid_hw1 for your submission to be correctly filtered.