+ 5
How do you determine the efficiency of an algorithm?
Which is more efficient: storing and iterating over a relatively large array, or just iterating over a giant range of numbers? I'm trying to understand the best algorithm for a program that finds prime numbers.
6 Respuestas
+ 11
I agree Vaibhav Dwivedi, "DRY" coding: Don't Repeat Yourself.
+ 5
Well, there's a bit of mathematical theory to know beforehand.
Have a look at this!
https://en.wikipedia.org/wiki/Big_O_notation
+ 5
Everytime we develop or write a code in any language, Our first priorities are that the code we develop must reduce time of execution and goal should be accomplished in less lines of code. Hence, I think it also implies on algorithm that it would be called efficient when it takes less time to execute and is covered in less lines of code.
+ 4
there are some simple ideas without too much theory:
even numbers are no primes ...2 is one
if you look for primes up to x, you only have to look up to sqrt(x) for divisors
+ 1
efficiency of an algorithm depends on time and space used if the more lines are there then memory used is more ,efficiency is less u could use time complexity in program by which time efficiency is found out
0
using space and time complexity