1. Engineering
  2. Computer Science
  3. 10 130 marks write a program that obtains the...

Question: 10 130 marks write a program that obtains the...

Question details

. 10. 130 marks] Write a program that obtains the execution times for the following three code segments with the different m code I x-i code 2: for {int i 0; i cena i++) for (int -ni+4 code 3: for (inti-0: for (int-0 n + Please record the execution time of the following tasks, Code when n-100, 1000, n 5,000, n 10,000, n100,000, n-1000,000, n 2,000,000, and n-10,000,000 Code 2 wbcn t-100, ธ-1,000. ถ-5,D00.ต-10,000..-100,000, and n-200,000 Code 3 when n-10, m-50, n-100, n-500, and n- ,000 You can fill a table like this n-10 l n-50 1 n 100 n2001 n10001… Code 1 Code 2 Code 3 Plotting the execution time of Code 1, Code 2 and Code 3. You may want to execute Codel, Code2 and Code 3 with more n values to plot You can use the following code templase to obtain the execution time. include ciostrean: inelude cetin for time funet ion include <chrono> vold get tine codel (int using clock chronoisteady clock elock:stime point start-clock: snOWDGet start tine perform the task Code 1 which you want to analyze the // execution ine int 0 elock:stime point end- elock: snow/Get end tine clock:sduration tine span - end -start double ns-double(tine span.count ) clock:sperLod: snun / clock: :perlod:sden
You can use the Sollowing code templatie to obeain the execution time include ciostrea include <etine i tor tine tunet on inelude cchrono void get tine code1 (int n) using clock- chronosssteady clocka clockistine point start-clockz snow)/Get start tine // perforn the task Code 1 which you want to analyze the // exeeutson tme nt0 for (int -0i -1 clock:stine point end- clocks snow: //Get end tine clock;:4uration time-span-end-#tart; double ns double ttime span.count ) clockssperiod: num clock::period: sdenz cout << Code 1 execution time for n-<<n i <ns seconds endl You ean put all functions in the le alglospp Please submit the peogram alg10.cpp, a seript file algl0zesult cetaining result, and the plot of execution time
Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution