CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: Time Complexity

  1. #1
    Join Date
    Nov 2008
    Posts
    23

    Time Complexity

    i have a c++ code here. Plz assisst me that if i want to calculate its time complexity considering it as an algorithm. How can i do that? What would be its time complexity?


    #include<iostream>
    #include<stdlib.h>

    using namespace std;

    int main(){
    int i, j, n;
    for(i=0;i<n; i++){

    for(j=0; j<n; j++){
    cout<<"my time complexity is = "<<i*j<<endl;
    }
    cout<<"complexity is increasing"<<j<<endl;
    }
    system("pause");
    return 0;
    }

  2. #2
    Join Date
    Mar 2002
    Location
    St. Petersburg, Florida, USA
    Posts
    12,125

    Re: Time Complexity

    Sounds like a homework assignment.....

    Did you read the "Why We DONT do Homework FAQ????"

    What reference book are you using to learn about time complexity?????

    What do YOU think is the answer??? And WHY?????
    TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
    2008, 2009,2010
    In theory, there is no difference between theory and practice; in practice there is.

    * Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions
    * How NOT to post a question here
    * Of course you read this carefully before you posted
    * Need homework help? Read this first

  3. #3
    Join Date
    Sep 2006
    Location
    Wantagh,NY
    Posts
    151

    Re: Time Complexity

    The time complexity has to do with the critical opeations being performed. In your program the critcal operations are being execurted in the for loops. I am only getting you started. Like others have said, if you want to learn, you need to do your homework.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured