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 ?
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
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.
Last edited by javaplus; March 3rd, 2010 at 06:49 AM.