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 456,472 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,795 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: 932 | Replies: 5
Reply
Join Date: Sep 2007
Posts: 6
Reputation: xraaz is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
xraaz xraaz is offline Offline
Newbie Poster

Question time and complexity

  #1  
Sep 15th, 2007
how much time this algoritham takes in theta notation

a <---- 0
for i <------1 to n do
for J <........ 1 to i do
for k <-------j to n do
a = a+1
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Aug 2006
Location: Egypt
Posts: 763
Reputation: RamyMahrous is on a distinguished road 
Rep Power: 4
Solved Threads: 59
Featured Poster
RamyMahrous's Avatar
RamyMahrous RamyMahrous is offline Offline
Master Poster

Re: time and complexity

  #2  
Sep 15th, 2007
I think not less than 2N.
Right?
B.Sc Computer Science, Helwan University
Microsoft Student Partner
Personal blog http://ramymahrous.blogspot.com/
Arabic technical blog http://fci-h-ar.blogspot.com/
English technical blog http://fci-h.blogspot.com/
Reply With Quote  
Join Date: Aug 2007
Location: Adelaide, South Australia
Posts: 428
Reputation: darkagn will become famous soon enough darkagn will become famous soon enough 
Rep Power: 3
Solved Threads: 53
darkagn's Avatar
darkagn darkagn is offline Offline
Posting Pro in Training

Re: time and complexity

  #3  
Sep 16th, 2007
a -> 1 step
For i = 1 to n -> takes n steps -> n+1 steps so far -> the 1 is negligible as n gets big so approx n steps so far
For j = 1 to i -> takes i steps for each n -> i*n so far -> approx n*n so far
For k = 1 to j -> takes j steps for each n*n -> j*n*n so far -> approx n*n*n so far
a = a+1 -> 1 step for each n*n*n -> 1*n*n*n

= n^3
Reply With Quote  
Join Date: Aug 2006
Location: Egypt
Posts: 763
Reputation: RamyMahrous is on a distinguished road 
Rep Power: 4
Solved Threads: 59
Featured Poster
RamyMahrous's Avatar
RamyMahrous RamyMahrous is offline Offline
Master Poster

Re: time and complexity

  #4  
Sep 16th, 2007
yea darkgen, you're right I think your solution is eligable
B.Sc Computer Science, Helwan University
Microsoft Student Partner
Personal blog http://ramymahrous.blogspot.com/
Arabic technical blog http://fci-h-ar.blogspot.com/
English technical blog http://fci-h.blogspot.com/
Reply With Quote  
Join Date: Sep 2007
Posts: 6
Reputation: xraaz is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
xraaz xraaz is offline Offline
Newbie Poster

Re: time and complexity

  #5  
Sep 16th, 2007
thanks for reply especially darkagn
Reply With Quote  
Join Date: Jun 2005
Location: Cambridge, MA
Posts: 1,304
Reputation: Rashakil Fol has a spectacular aura about Rashakil Fol has a spectacular aura about 
Rep Power: 7
Solved Threads: 41
Colleague
Rashakil Fol's Avatar
Rashakil Fol Rashakil Fol is offline Offline
Salamander Man

Re: time and complexity

  #6  
Sep 17th, 2007
Should take something n^3 * log(n) given integers represented as products of primes.
You can adblock jbennet's avatar.
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 2:32 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC