Question
Specify T(n) for each of the fragments below. Give a Big-Oh analysis of the running time. a. Calculate the constant c and nofor each fragment.
Specify T(n) for each of the fragments below.
Give a Big-Oh analysis of the running time.
a. Calculate the constant c and nofor each fragment.
Implement the code and run for several values N: 10, 100, 1000, 10,000. Prior to executing the
for loop for each code fragment, your code should use the gettimeofday function that is defined in
For each value of N, execute your code five times and compute the average elapsed time. Your program should print out the elapsed time values and the average value for each value of N. Take a screenshot of the output and include the screen shot in your write-up.
help make a graph of the measurements for each code fragment and include the graph in your write-up.
Compare your Big-Oh analysis with the actual running times.
Your write up should include the Big-Oh analysis of each code fragment, the experimental
results from item 2, and your comparison of Big-Oh analysis with the actual running times.
Fragment #1 int sum = 0; for (inti=0;i sum++; Fragment #2 int sum = 0; for (int i=0; i < n; i+=2) sum++; Fragment #3 int sum = 0; for (int i=0; i for (int j=0; j Fragment #4 Int sum = 0; for (int i=0; i sum++; for (int j=0; j
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