Overview
This lab covers some concepts in the course schedale through the Functions section.We will rebearse various concepts using epop code on the course servec,esing it as a velicle to traverse the learning landscape.
For course server directions,please refer to links posted on D2L,under Materials/Content/ References.
Because epop programs for this lab are being run from the Unix command line,there is no need to invoke the epop environment.However,you may still want to start the epop environment for testing and exploration.If so,then please note that you exit epop by typing BYE.(This is different from how one exits a Unix login with the exit command.)
Grading of your work will depend on your demonatuated porticipation in the lab.You are not being graded on error free coding.
For a recap of details on the programming emironment,please refer to Lab 1 .
Utility code for this lab
Consider using epopy randon number generator to generate a lists of random numbers as follows:Tasks(equally weiphied for scoring)-Perform direr sais witho jour docs director: the following values of wi X .Element count.
N=n_(1) of n_(n)
Sam.
\sum x=s_(1) s_(2) cdots s_(0)
Average. The sum divided by the lengh.
(\sum x)/(N)=n_(1) n_(2) cdots n_(n)
Dot Product. This is a one-to-oce relationship between the list and itself, effectively a sum of squares.
x*x=x_(i1)x_(i1) x_(i1)x_(i2) cdots x_(ik)x_(in)
Sum of Pairwise Prodocts. This is a many-to-eney relabionhip between the list and itself, the sum of their many prodacts.
x\times x=x_(11)x_(21) x_(11)x_(21) x_(11)x_(33) cdots x_(14)x_(16)
Using text editot, asemble thest tasks inside a filt called lablarpep. Tent your code with:
roop RUN "pwf/Aab-la.reop
Task B - Write a Big-O calculater that takes user input and primes of total operations and the Big-O. The following assumptions are made:
c
is a constant bair applies to large and small values of
n
operations. Also, CPU and memory performance are comidered coestant over n.
If a program of
O(n^(2))
biles 10 suconds with 10.000 elruens, how much time will procesuing 30,000 elements requee?
Use these inputs for compunise estimated
C
yme for
C(A^(3))
ar for
T(n)-<\times n^(3)
.
sample N=10,000
target N=30,000
sampletime -10
Solve for e:Output, plugging
c
and fargel
N
into estimater Time equation
c\times n^(2)
:
estimatedryme -e\times 30,000^(2)-10^(-7)\times 30,000^(2)-90 recends
Suppose the algorithm is
O(l_(0g2)n)
. What would be the manber of operations to process 10,000 elements? From this answer, estimate be na-time given be timing information for the prior task.
Using text editor, assemble these tasks inside a file called labibepop. Test your code with:
epop RUN 'pwd'/lab-3b.epop
Task
C-In
( code comments ) for those functions in tak A , remark about the following:
Big-O if the specific number of required operations is known.
Big-O if the specific number of required operations not knows.
The timing (in manoseconds) of each function (fire use the built-in BENCH timing function).
Extra credit (10%): Devise an extra algorithm to auneraically compute the task A function's operational counts and Big-O. (Olint: Integrate ideas from tunk B instank A.)