4 Replies - 772 Views - Last Post: 21 November 2011 - 01:53 PM Rate Topic: -----

#1 Nady990   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 21-November 11

question : complexity of an algorithm

Posted 21 November 2011 - 01:00 PM

what is the complexity of each algorithm :

 int f2 (int n) {
     int x = 0;
     for (int i=1; i < n ; i++) {
         for (double j=sqrt(i); j <= n ; j+=sqrt(i)) {
                ++x;
        }
     }
    return x;
	}
	



 
int f1 (int n) {
    int x;
    for (int i=n; i > n/2 ; i--) {
         for (int j=2; j < n ; j=2*j) {
            x = power(2,j); 
            while (x > 2) {
               x = sqrt(x);
            }
         }
    }
    return f1(n/3);
}




Is This A Good Question/Topic? 0
  • +

Replies To: question : complexity of an algorithm

#2 Wuzseen   User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 72
  • Joined: 04-October 11

Re: question : complexity of an algorithm

Posted 21 November 2011 - 01:03 PM

You're going to have to be a bit more specific than that. Complexity is rather vague--relative to what?

One function uses recursion?

EDIT: I'm a derp.

This post has been edited by Wuzseen: 21 November 2011 - 01:12 PM

Was This Post Helpful? 0
  • +
  • -

#3 CTphpnwb   User is offline

  • D.I.C Lover
  • member icon

Reputation: 3802
  • View blog
  • Posts: 13,798
  • Joined: 08-August 08

Re: question : complexity of an algorithm

Posted 21 November 2011 - 01:09 PM

Taking the same class as this person?

If you don't make the effort to do a little research on your own you're going to find programming to be very difficult. (It didn't take much effort to find that topic.)
Was This Post Helpful? 0
  • +
  • -

#4 sepp2k   User is offline

  • D.I.C Lover
  • member icon

Reputation: 2644
  • View blog
  • Posts: 4,225
  • Joined: 21-June 11

Re: question : complexity of an algorithm

Posted 21 November 2011 - 01:10 PM

Both of these have been asked before, quite recently in fact. Guess you're not the only one from your course using this forum to do your homework.
Was This Post Helpful? 0
  • +
  • -

#5 born2c0de   User is offline

  • printf("I'm a %XR",195936478);
  • member icon

Reputation: 187
  • View blog
  • Posts: 4,673
  • Joined: 26-November 04

Re: question : complexity of an algorithm

Posted 21 November 2011 - 01:53 PM

Just read the entire thread of KYA's tutorial here and you'll find your solutions.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1