Since the running time of the maximum_n_ind() is O(N*M)
and the running time of the quicksort algorithm averages
as O(N*ln(N)) with a worst case of O(N**2) you'll do better
with qsort first when ln(N) is about M in size which is 17
for N = 5000**2.  That means that for small M doing the
qsort second is best but for large N doing qsort as Derek
suggested will be faster.

If you really need to optimize your performance, you need
to time the various approaches to see which is faster and
when.

Hope this helps,
Chris

On Mon, Oct 20, 2014 at 9:50 AM, Chris Marshall <[email protected]> wrote:
> qsort is using quicksort so the performance is that of
> quicksort.  It would probably be faster to use maximum_n_ind
> with an appropriately large number for N and then use qsort
> or uniq to determine which elements you need.
>
> --Chris
>
> On Mon, Oct 20, 2014 at 4:17 AM, Ronak Agrawal <[email protected]> wrote:
>>
>> Thanks Chris and Derek for the optimized method
>>
>> For unique I was going to use squaretotri() and then sort it
>> The rle had went out of my mind...
>>
>> I have a doubt, is it efficient to use the qsort method in large matrix (
>> say 5000 x 5000)

_______________________________________________
Perldl mailing list
[email protected]
http://mailman.jach.hawaii.edu/mailman/listinfo/perldl

Reply via email to