GIDForums  

Go Back   GIDForums > Computer Programming Forums > C++ Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 06-Nov-2008, 17:25
cpit cpit is offline
Junior Member
 
Join Date: Jan 2006
Posts: 73
cpit is on a distinguished road

Time complexity of random loops


Hi all,

I have a doubt about the asymptotic complexity of random loops. For instance, consider the loop:

while(x < rand()){
do something;
}

Is the complexity of this loop O(x), O(1) or even another?

Thanks in advance for your help.
  #2  
Old 06-Nov-2008, 18:25
Blake's Avatar
Blake Blake is offline
Member
 
Join Date: Nov 2005
Posts: 255
Blake is a jewel in the roughBlake is a jewel in the rough

Re: Time complexity of random loops


With algorithms that involve randomness, you need to talk about the expected running time. Quicksort is a good example. The worst case run time is quadratic if you're extremely unlucky with the random numbers that you pick, but the expected running time is O(nlog(n)).
__________________
www.blake-foster.com
  #3  
Old 10-Nov-2008, 02:22
n00pster n00pster is offline
Junior Member
 
Join Date: Sep 2008
Location: Miami
Posts: 40
n00pster will become famous soon enough

Re: Time complexity of random loops


Quote:
Originally Posted by cpit
Hi all,

I have .

Interesting, my guess is that its complexity is inf, because in the worst case this can be an infinite loop. But I feel that I might be wrong. I would love to see other's comments.
Last edited by n00pster : 10-Nov-2008 at 03:15.
 
 

Recent GIDBlogToyota - 2009 May Promotion by Nihal

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
BryanSoft.Com Free Cpanel Hosting And Resellers One Time Posting!!! rewer Free Web Hosting 0 22-Oct-2008 20:56
Asynchronous transfer question crystalattice Miscellaneous Programming Forum 2 24-Jan-2007 21:39
constructors/classes mapes479 C++ Forum 3 19-Nov-2006 18:34
[CONTEST?]Data Structure Test dsmith C Programming Language 2 06-Jun-2004 16:13

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 15:20.


vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.