[Coco] the final stage of optimization
Steven Hirsch
snhirsch at gmail.com
Fri Nov 20 17:26:39 EST 2009
On Fri, 20 Nov 2009, Wayne Campbell wrote:
> I googled quicksort. The wiki page is very informative. While reading
> it, I remembered how I wrote the sorts in DCom. They were based on
> quicksort. Because they were contained in separate procedures, I was
> able to use them recursively, and that's what made it work.
>
> In decode, the sorts and searches are part of that procedure, and not
> separate. This rules out recursion, as I can't call decode repeatedly.
> But I did gain an understanding I didn't previously have. I need to deal
> with the records to be searched or sorted in groups. This will require
> extra code to determine if a split is required, and how to divide it.
> I'm reasonably certain that a n/2 division will be faster, but I may be
> able to have it do a n/4 division when the number of records becomes
> greater than a specific number.
>
> I think that doing it this way will speed things up because it won't
> have to search every record to find a match. We'll see.
I'm not entirely sure I understand what you are doing/trying to do. Do
you need to maintain sorted and searchable set of items dynamically? If
so, perhaps what you need is a tree or heap structure. The insertion will
be on average O(LogN) instead of the constant time insertion cost of a
list, but it maintains the sequence and can be searched in the same
O(LogN) time.
Steve
--
More information about the Coco
mailing list