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.

Results 1 to 3 of 3

Thread: Big-O Question

  1. #1
    Junior Member
    Join Date
    Feb 2010
    Posts
    18
    My Mood
    Amazed
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Question Big-O Question

    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 ?


  2. #2
    Super Moderator helloworld922's Avatar
    Join Date
    Jun 2009
    Posts
    2,896
    Thanks
    23
    Thanked 619 Times in 561 Posts
    Blog Entries
    18

    Default Re: Big-O Question

    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.

  3. #3
    Junior Member
    Join Date
    Mar 2010
    Posts
    3
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Big-O Question

    Quote Originally Posted by Kumarrrr View Post
    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 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.