How do I find the estimated number of comparisons, using a sorting algorithm on a data set?

40 Views Asked by At

just wanted to ask;

So if I have a sorting algorithm that performs e.g. n log2 n comparisons And I consider this on a data set of for example; 11,000,000 records/elements

How would I find out how many comparisons are made and how do I found out the computation time? Lets say the computers perform 10^8 operations per second.

1

There are 1 best solutions below

0
On

For a sorting algorithm the complexity is usually given dependent on the number of elements to be sorted. Usually the comparisons are counted. This means that if your sorting algorithm does $n log(n)$ comparisons, n means usually the number of elements. Now you were given 11'000'000 elements. In order to compute the estimated number of comparisons you just plug in 11'000'000 for n. Now that you have the estimated number of comparisons, you have to divide by 10^8 to get the number of seconds your computation takes.