baxy77bax has asked for the wisdom of the Perl Monks concerning the following question:
I was wondering does anyone know a trick to reduce memory requirement during a bucket sort without significantly reducing the speed
Let say I have 30 numbers:
in order to sort them using bucket sort algorithm i would need to either create an array of size 75434532 and assign each number to a bucket. duplicates are resolved using linked lists. another strategy is to avoid arrays and create a linked list and then upon insertion re-assign pointers. However in order to figure out where a number needs to be inserted a binary search needs to be implemented (so O(log N) algorithm instead array based O(1) -> N -average size of the list) plus if the procedure is repeated many times over each allocated memory unit has to be freed (erased) after the sort in order to be used again without any memory leaks (ok perl has a GC so that is not that difficult to do - but still some time needs to be wasted in order to do it).2 53 23456 75434532 233 45654 665446 33 234 5 6665 3 2 23 43 62553 27263 2 33 75434532 987762 34455 22 3345 24 567 54 43 12 23
are there any other solutions or is that it?? Are there any other fast O(M) algorithms fo sorting (M - the number of elements)?
thnx
|
|---|