# question : complexity of an algorithm

Page 1 of 1

## 4 Replies - 778 Views - Last Post: 21 November 2011 - 01:53 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'https://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=256656&amp;s=f5fe037d683b05333f8f9b9aff4e76df&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

Reputation: 0
• 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

Reputation: 3
• 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

### #3 CTphpnwb

• D.I.C Lover

Reputation: 3806
• Posts: 13,827
• 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.)

### #4 sepp2k

• D.I.C Lover

Reputation: 2678
• Posts: 4,277
• 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.

### #5 born2c0de

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

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

## Re: question : complexity of an algorithm

Posted 21 November 2011 - 01:53 PM

Page 1 of 1

 .related ul { list-style-type: circle; font-size: 12px; font-weight: bold; } .related li { margin-bottom: 5px; background-position: left 7px !important; margin-left: -35px; } .related h2 { font-size: 18px; font-weight: bold; } .related a { color: blue; }