Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Assignment 1 For this assignment, you are to work in groups of 2 or 3 . This assignment should provide you with experience in the
Assignment
For this assignment, you are to work in groups of or This assignment should
provide you with experience in the analysis of algorithms.
What to include in your submission:
One zip folder named appropriately
containing:
o A PDF containing your answers to questions # #
o A Python file and a C file. Make sure each programs header block
comment includes your name.
Complete the following:
marks You are given a Python program, Assignmentpy which will allow
you to perform experimental analysis of two algorithms which you will need to code.
a Read the starter code to understand what it does.
b Complete the program by writing the code for the two functions
prefixaverages and prefixaverages given the pseudocode
provided at the end of this document in Appendix A Run the program on
small input sizes to ensure the functions execute as expected. For example, if
n and your input array is the prefix averages computed
would be: Please note: you are free to add any
other code to the program to help you during testing.
mark Once you are sure your program works, you are now ready to perform
experimental analysis on large input sizes. Decide on an appropriate initial input
size, n but keep in mind that the program will also execute on input sizes nn
nn nn and nnSo if n is then n would be
a For each function, record the times you obtained in a table like the one shown
below: Note that the starter code is set up such that for each input size, the
algorithm will execute times.
Check the Class Plan for Assignment submission requirements
Input Size Run # Run # Run # Average Execution Time sec
n
n
n
n
n
Please note the following:
If your timings are erratic egs or there is no clear increase in
time with respect to input size try starting with a larger input size.
The goal is to slow the program down enough to be able to
determine how time grows as the input size grows.
You are not required to use the same initial input size for both
functions.
b Plot the average running times obtained in part a as a function of n as scatter
plots on a linear scale for each algorithm.
marks For each function prefixaverages and prefixaverages complete the
table given below to help you determine the growth of running time with respect to
the size of the input. Clearly state the experimental growth rate of the function given
your execution times: does it look more like
Input size Average
Execution
time in ms
as determined
by
experiment
Actual Time
Increase Ratio:
Calculate
Time increase
factor if On:
Calculate
Time increase
factor if On
:
Calculate
n t NA NA NA
n t
n t
n t
n t
marks Repeat Questions # # above using the C file, Assignmentc as
your starting point.
mark Given the experimental analysis you performed for prefixaverages
and prefixaverages using Python and C do the experimental growth rates
align with the theoretical growth rates of these algorithms? If not, please provide
possible reasons for the discrepancies.
marks Al Gorythm, who is well versed in Pythons builtin functions, claims the
prefix averages algorithm could be improved if one uses Pythons builtin mean
function
The result is prefixaverages which is also given in Appendix A
prefixaverages produces the correct output using fewer lines than the other
two versions, yet how does this version compare to prefixaverages and
prefixaverages in terms of growth rate? Add code to the Python program to
include prefixaverages Perform experimental analysis for this new version
as you did for prefixaverages and prefixaverages and report
your findings. Explain why or why not Als algorithm is the best of the three versions.
marks Assume prefixaverages on an input size of n five
hundred thousand takes minutes. Given that time, what do you predict the
execution time to be when the input size grows to n ie Justify your
prediction.
marks Assume prefixaverages on an input size of n
million takes seconds. Given that time, what do you predict the execution time to
be when the input size grows to n ie Justify your prediction.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started