Oct 24, 2013, 12:15 PM
Post #12 of 13
Re: [zapzap] Finding the Max of An Array
[In reply to]
Nice work there Laurent! You're right, I shouldn't need to sort the data. But this is not my 'data'. Thank you for submitting your proposal instead of simply noting my 'algorithm stinks'.
It looks like you stored your results in an array as well as I did and the person before myself did.
Hmm, sorry, I mixed you up with the OP.
I used an array to store the data only because I wanted to keep as close as possible to your solution, just changing what I thought needed to be changed in terms of basic algorithm.
As for the "stinking" algorithm, sorry about that, nothing personal, I did not want to be derogatory, but just to say that sorting the data to find the smallest or largest value can be a huge performance overhead if the data set is large. When I wrote that message, I did not have enough time to fully elaborate, but, as you know, I came back later to give a possible alternate solution.
I am working daily with really huge dataset (dozens of GB), so, I would usually avoid loading data into an array but prefer to iterate over the file (even doing it twice if necessary), but when I know for sure that the data is going to be small, I have no problem with loading such data into memory if it will buy me some other advantage.