A
A
Arbil2019-12-18 07:34:09
Algorithms
Arbil, 2019-12-18 07:34:09

Why is the speed of an algorithm measured in number of operations and not in seconds?

Hello!
I'm wondering
Why is the speed of the algorithm measured in number of operations and not in seconds?
Couldn't it be that a multiple line program runs faster than a two line function (built-in)?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Rsa97, 2019-12-18
@Arbil

And what will seconds give you?
Here you have two programs that process the same data and get the same results using different algorithms. The first program does it in 10 seconds, the second in 20. How to estimate how much the processing time will increase with an increase in the amount of data by 10 times?
No way, until we know the complexity of the algorithm. If the first has complexity O(n 2 ), and the second - O(n), then the running time of the first will increase by 100 times and will be 1000 seconds, and the second - only 10 times (200 seconds). That is, a program that was faster on a small dataset suddenly becomes much slower on a large dataset. And the determining parameter here is precisely the computational complexity of the algorithm.

D
dollar, 2019-12-18
@dollar

Because the speed of execution depends on the frequency and type of processor, and in our time, on the number of cores / processors (threads).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question