Search found 6 matches
- Wed Jun 25, 2003 6:01 pm
- Forum: Algorithms
- Topic: Find second min number .
- Replies: 10
- Views: 5318
Re: Find second min number .
This is an intreasting solution but I think it is not a good idea. It could be fast but it waste a lot of memory. To list all elements that are beaten by each number took n*n/2 elements! This mean that you'll get out of memory very soon (about on 100000 elements).
This is my idea:
...
What do you ...
- Wed Jun 25, 2003 12:33 pm
- Forum: Other words
- Topic: acm solve sites
- Replies: 51
- Views: 31590
- Wed Jun 25, 2003 12:10 pm
- Forum: Algorithms
- Topic: Find second min number .
- Replies: 10
- Views: 5318
Re: Find second min number .
Now, the second smallest must have been beaten by the smallest. So just scan through the list of elements beaten by the smallest, and find the minimum value in this list. The list has lg(n) elements, so this takes lg(n) - 1 comparisons. Therefore, the total # of comparisons is always n - 1 + lg(n ...
- Wed Jun 25, 2003 10:56 am
- Forum: Other words
- Topic: acm solve sites
- Replies: 51
- Views: 31590
Re: acm solve sites
Nobody can learn programming without studing solutions of other programmers.
Every book and course that teach the art of programming show algorithms written by someone else. This is the only way.
I think solutions should be accessible by everyone.
Mattia
ps: sorry for my terrible english.
Every book and course that teach the art of programming show algorithms written by someone else. This is the only way.
I think solutions should be accessible by everyone.
Mattia
ps: sorry for my terrible english.
- Mon May 12, 2003 10:22 pm
- Forum: Volume 1 (100-199)
- Topic: 100 - The 3n + 1 problem
- Replies: 1394
- Views: 320809
Re: problem 100 (insane timings) and general tricks
I saw alot of things in your code. Non-dynamic arrays in C++ are automatically initialized to zero, so setting the array to 0 is redundant. m%2 is fine, but m & 1 is able to check for an odd number, only with a grand total of one instruction.
I'm not sure why you hardcoded your table to 30,000 ...
- Thu May 01, 2003 10:40 am
- Forum: Volume 1 (100-199)
- Topic: 100 - The 3n + 1 problem
- Replies: 1394
- Views: 320809
Re: problem 100 (insane timings) and general tricks
Hi people,
I was just curious on knowing how people get such great speed ups on their problems. For eg. I just did prob. 100 and got a timing of 3.18 .
....
Is there a better way to do this? Do you code in assembly to get such high speedups?? Or is there a better algorithm. I am very interested in ...
I was just curious on knowing how people get such great speed ups on their problems. For eg. I just did prob. 100 and got a timing of 3.18 .
....
Is there a better way to do this? Do you code in assembly to get such high speedups?? Or is there a better algorithm. I am very interested in ...