User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Computer Science and Software Design section within the Software Development category of DaniWeb, a massive community of 427,196 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,159 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Computer Science and Software Design advertiser: Programming Forums
Views: 64435 | Replies: 56
Reply
Join Date: Oct 2007
Posts: 2
Reputation: CaribGirlC is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
CaribGirlC CaribGirlC is offline Offline
Newbie Poster

Re: Time complexity of algorithm

  #51  
Oct 15th, 2007
hi, im trying to do the dominant behaviour, which will compute the total run time, but im not sure if im on the right track. heres what i have:

Function mystery(n)
r = 0
for i = 1 to n -1 do
for j = i + 1 to n do
for k = 1 to j do
r = r + 1
return r
END


first thought
the function sets the value of r to 1 (one operation). then it tests the second loop to loop 1 to n- 1 times...(it runs the body of the for loop exactly n - 1 times. the body performs two other for loops; ' j, which is i + 1 to n ' and ' k which runs 1 to j times.'

other thought
the outer most loop executes n-1 times (worst case?). the next innermost one on the order exectures i + n-1 times (loops based on first for loop?).
the addition is based on two for loops....


any suggestions, id appreciate it...
Last edited by CaribGirlC : Oct 15th, 2007 at 3:08 pm.
Reply With Quote  
Join Date: Oct 2007
Posts: 2
Reputation: CaribGirlC is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
CaribGirlC CaribGirlC is offline Offline
Newbie Poster

Re: Time complexity of algorithm

  #52  
Oct 15th, 2007
Originally Posted by Rashakil Fol View Post
UML has a time complexity of O(n^n) while OOAD has a time complexity of O(n!).


couldnt have said it better ...
Reply With Quote  
Join Date: Mar 2008
Posts: 2
Reputation: cybertee1 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
cybertee1 cybertee1 is offline Offline
Newbie Poster

Question Re: Time complexity of algorithm

  #53  
Mar 10th, 2008
need explanation on finding order of growth of a recusive function example what is the order of growth given that T(1)=1 and T(n)=2T(n/4) + 1 for n>0
what are the steps to find ORDER OF GROWTH OF ANY function.
Reply With Quote  
Join Date: Mar 2008
Posts: 2
Reputation: cybertee1 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
cybertee1 cybertee1 is offline Offline
Newbie Poster

Re: Time complexity of algorithm

  #54  
Mar 10th, 2008
steps or methods of order og growth of a function
Reply With Quote  
Join Date: Oct 2007
Location: Cambridge, MA
Posts: 269
Reputation: sarehu is on a distinguished road 
Rep Power: 2
Solved Threads: 22
sarehu's Avatar
sarehu sarehu is offline Offline
Posting Whiz in Training

Re: Time complexity of algorithm

  #55  
Mar 11th, 2008
For any function?

Here's a tip: For any function f, f(n) = O(f(n)). It's true! He he he.

Now, given T(1) = 1 and T(n) = 2T(n/4) + 1, you can find the order of growth using the Master theorem.

One way, though, to think about the above problem intuitively, is to ask what the statement "T(n) = 2T(n/4)+1" really means. Another way of writing it is to say, "T(4n) = 2T(n) + 1". That is, every time you multiply n by four, the value of T(n) multiplies by 2. (For large values of n, adding 1 has a negligible effect.)

What function has that property, where multiplying the input by four results in the output being multiplied by 2? We know the function is sublinear, because if it were linear, we would find that T(4n) is approximately 4T(n), for large n. But it's only 2T(n)

We know it's bigger than logarithmic, because we know that for logarithmic functions, multiplying a constant by the input results in a mere constant being added to the output.

So, what function has the property that T(4n) is 2T(n)? Make some guesses. And this will be the function that conveniently represents your order of growth.
Last edited by sarehu : Mar 11th, 2008 at 12:11 am.
Reply With Quote  
Join Date: Oct 2008
Posts: 1
Reputation: galeon is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
galeon galeon is offline Offline
Newbie Poster

Re: Time complexity of algorithm

  #56  
2 Days Ago
some one help me please...
how will i compute the time complexity of these algo...


do{
h=h-1
}while(h!=n);
Reply With Quote  
Join Date: Oct 2008
Posts: 14
Reputation: shrughes is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 1
shrughes shrughes is offline Offline
Newbie Poster

Re: Time complexity of algorithm

  #57  
2 Days Ago
Very carefully, I hope! Why don't you start by learning how to compute time complexity for algorithms, in general.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb Computer Science and Software Design Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the Computer Science and Software Design Forum

All times are GMT -4. The time now is 10:28 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC