Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Apriorna slozenost rekurzivne funkcije
Author Message
danielvast Offline
Forumaš
***

Posts: 424
Joined: Dec 2009
Reputation: 22
Post: #1
Apriorna slozenost rekurzivne funkcije
Ej ljudi mala pomoć ako itko zna koja je apriorna složenost rekurzivne funkcije npr:
Code:
int fib(int n){
    if(n<=1) return 1;
    return fib(n-1)+fib(n-2);
}
2^n ili n^2.
Unaprijed hvala

"When all else fails, read the manual."
23-02-2010 11:28 AM
Find all posts by this user Quote this message in a reply
schmrz Offline
____
*

Posts: 569
Joined: Feb 2007
Post: #2
RE: Apriorna slozenost rekurzivne funkcije
O(n^2) :)

Mada nisam 100% siguran. Znao sam nekada tačno analizirati algoritme, gledao sam neka predavanja sa MIT-a ako se ne varam pa ih možeš potražiti. Ali je to bilo podavno, a nije mi trebalo i onda se tako zaboravi...

I have no drinking problems. I drink. Get drunk. Fall down. NO PROBLEM
Registered As Linux User #484215
Moj skromni blog
Savjet za buduće programere: ovdje
23-02-2010 11:51 AM
Find all posts by this user Quote this message in a reply
kecko Offline
Forumaš
***

Posts: 647
Joined: Nov 2009
Reputation: 20
Post: #3
RE: Apriorna slozenost rekurzivne funkcije
slažem se sa schmrzom n^2 je jer se u n puta poziva 2X fib()...
(This post was last modified: 23-02-2010 12:06 PM by kecko.)
23-02-2010 12:03 PM
Find all posts by this user Quote this message in a reply
danielvast Offline
Forumaš
***

Posts: 424
Joined: Dec 2009
Reputation: 22
Post: #4
RE: Apriorna slozenost rekurzivne funkcije
OK hvala vam velika !!Palac-gore

"When all else fails, read the manual."
23-02-2010 12:43 PM
Find all posts by this user Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 1 Guest(s)