Hi,
How do I find the time efficiency of a algorithm that requires 1000 basic operations, regardless of the amount of data input.
Also, what is meant by 1000 basic operations ?
Printable View
Hi,
How do I find the time efficiency of a algorithm that requires 1000 basic operations, regardless of the amount of data input.
Also, what is meant by 1000 basic operations ?
A basic operation is the simplest possible action that the computer can perform. The Big-O time efficiency describes the relation between running time and the size of the data inputted (actually, it's used for other things as well, such as describing the decay of errors). So, if a function doesn't depend at all on the size of the input data, it is said to be O(1), meaning that no matter what the data input size, it's going to take the same amount of time.
A basic operation is anything that can be performed in constant time. For example, a comparison can be a basic operation. Or a FLOP (floating point multiply + add + assignment) can be a basic operation. Or you can define a basic operation to be 100 multiplications.
Time efficiency of an algorithm that requires 1000 basic operations, for an arbitrarily long input is O(1).
If you assume your have N input points, and your algorithm performs 100N operations, then the time complexity of the algorithm is O(N).
If your algorithm performs (a N^2 + b) or (a 2^N + b) operations, then time complexity is O(N^2) and O(2^N) respectively. As long as 'a' and 'b' are constants, it does not affect the order denoted by big O notation.