Search found 6 matches

by matt80
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 ...
by matt80
Wed Jun 25, 2003 12:33 pm
Forum: Other words
Topic: acm solve sites
Replies: 51
Views: 31590


And if solutions of this problemset are available, there would be some cheaters who send the solution without thinking about it how it works.

ok, but I think this is their problem, not mine. Only the one who wrote the solution for the first time should be proude aboute it. I think this is not a ...
by matt80
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 ...
by matt80
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.
by matt80
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 ...
by matt80
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 ...

Go to advanced search