Re: Optimizing basic operations

new topic     » goto parent     » topic index » view thread      » older message » newer message
gimlet said...

Basically you are doing too much work. The only requirements we really need are:

1. That we know the minimum record for the top 100, the others do not concern us.

2. A data structure which will efficiently provide us with that (eg: a heap). See Wikipedia 'Heap (data structure)' only reverse the conditon so that root is the minimum and items are greater than or equal to their parent node.

This is a good solution as it uses constant space and an (optimal) single read of the data.

Yep, that's pretty much exactly what I suggested too. Only instead of a min-heap structure I just used a sorted sequence with a binary search for insertions - which would be much fast than a heap structure.

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu