+ 1
How can i run this code for 20 times, then take the average (20times) of Merge sort and Quick sort ? Help please 🖐️ Just ideas)
12 Antworten
+ 3
Parham that's only pseudo code. You have to make a real C code from that. All what you have to do is: Let both of your algorithm 20 times run and get the time for that. Sum up the time for every run, or get the start time at the beginn of to 20 loops and at the end of the 20 loops. Then divide it by 20. That's all.
+ 3
Just do:
timeSum = 0
For i = 0, i<20, i++
startT
run algorithm
stopT
timeSum += stopT - startT
time Avg = timeSum / 20
+ 3
Parham Parham look at this.
But be careful. I did this for the first time. And I am not a C specialist. And the result amazes me. Are you sure the sorting algorithms are working well? There is a very large time difference between the two.
https://code.sololearn.com/cMGeyo596f9R/?ref=app
+ 2
There will be answere yo take average from then ..... This line is not clear or given any example
+ 2
Do an internet search for:
c++ measuring execution time
+ 1
Your question is not clear rewrite in easy way what actually u want i think are talking about the running time of both algorithms
0
The teacher said you got to run this and there will be answers to take average from then , are you saying sould i give the code time to get different responds ? ♨️A.S.♨️
0
I mean , the teacher said we should run this code 20 times,
and for example numbers will be 15 for QS and 8 for MS . Next run other answers and ....
Then take average of 20 time running (20 QS answers & 20 MS answers) the algorithm in Excel , i think i said it right
♨️A.S.♨️ by the way tnx for ur time
0
♨️A.S.♨️
It's not about excel , just the code , can i get different answers by 20 times running the code? What's your opinion
https://code.sololearn.com/cQVSliIV0ZXW/?ref=app
0
Coding Cat
Couldn't do much with the change
0
Martin Taylor
Thank for your checking and opinion 🙌
I gotta work more on it )
0
Coding Cat thanks you that you have witten a code 🙌🪶and your right
it's a lot of difference between answers that code says Parham Parham look at this.
But be careful. I did this for the first time. And I am not a C specialist. And the result amazes me. Are you sure the sorting algorithms are working well? There is a very large time difference between the two.
https://code.sololearn.com/cMGeyo596f9R/?ref=app