Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 HELP!!! Random numbers and an array
Index -> Programming, Turing -> Turing Help
Goto page Previous  1, 2
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Maverick




PostPosted: Tue Jan 13, 2004 7:23 pm   Post subject: (No subject)

Hmm I get it? Doh! Hit Wall
Sponsor
Sponsor
Sponsor
sponsor
Andy




PostPosted: Tue Jan 13, 2004 8:06 pm   Post subject: (No subject)

lol mickey doesnt know java
McKenzie




PostPosted: Tue Jan 13, 2004 8:56 pm   Post subject: (No subject)

Very Happy Well I don't know Java yet, I do plan on teaching it next year for the gr12 class. But seriously the language won't effect the outcome. Consider the following:
code:

for a 100000 element array
# filled       | approx num tries per   |  sub-total
-------------------------------------------
0-50000        |   1.4                  |  70001
50001-75000    |   2.8                  |  70000
75001-95000    |   8.9                  | 178000
95000-99000    |   45                   | 180045
99001-99900    |   255                  | 229500
99900-99999    |   5110                 | 511000
                           Total        |1238546

for 100000 elements that makes it of order n. 12.3 n is of order n.
Dauntless




PostPosted: Tue Jan 13, 2004 9:01 pm   Post subject: (No subject)

Help!! Random numbers and an array!

or

How helping a new programmer can turn into a battle of the titans.
Tony




PostPosted: Tue Jan 13, 2004 9:05 pm   Post subject: (No subject)

Laughing

bah... thats what I get for theoretical programming Rolling Eyes
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Tony




PostPosted: Sat Jan 17, 2004 8:49 pm   Post subject: (No subject)

ha, I knew I was right Very Happy

I was looking at my code and though - "what the hell was that guy thinking?"

then I realized it was my code and fixed it. Edited version of algorythm is found in the same place

the problem was how I was shifting my array. I used to throw out one element and moved everything to the left from that point on. But then (now) I figured that there was no point in keeping the remainding numbers in order so I just moved the last element in place of one to be deleted Laughing

the result? this cut down the execution speed to just 2% of previous algorythm (tested at size=1000) Laughing

McKenzie - would you like to run some more tests now Wink I think I have a better chance.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 2 of 2  [ 21 Posts ]
Goto page Previous  1, 2
Jump to:   


Style:  
Search: