Re: Optimizing basic operations
- Posted by jaygade Aug 01, 2013
- 5974 views
Let me see if I understand your problem so far:
- Receive a data structure containing an evaluation and two lists of 25 integers. The evaluation is the result of some calculation.
- Add the data to a list, keeping the list sorted by the value of evaluation as the data are received sequentially.
- The list can grow to a very large size.
This sounds like a good combination for insertion sort from the standard library, especially if scores will be coming in sequentially. I believe that it will be more efficient to build and maintain a sorted list than it will be to read in all the values and sort them afterward. Especially if you are talking "trillions of values". You may not even be able to keep the entire list in memory at once. Edit: The only constraint is if you somehow receive more values than you can sort in a certain amount of time.
Is the evaluation dependent on either list of 25 integers? Do the integer lists need to be sorted independently?
Note: I'm not an expert on sorting itself, just my reading of the manual and layman's knowledge of sorting and complexity.
Can you give a better pseudocode explanation of what you are trying to do? I started working on a test/example from what you had said before, but your new information brings with it new assumptions.