Re: find the largest 1000 values
Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance
George wrote:
Thanks Klueless,
I understand your solution now. I have a new idea of using STL nth_element
algorithm, and each time I read a number of data which my memory can afford,
then I input (start_index, 1000, end_index) to nth_element which could save
time to sort (since we only need to the largest 1000 values, no sort is
needed). Then do a loop, each time keep the 1000 largest values returned from
nth_element and read the remaining ones.
How do you think of this solution? I am wondering the time complexity of
nth_element, do you have any ideas?
I think nth_element should be linear. so the complexity depends on the
size of data collection in your solution.
Best Regards.
.
Relevant Pages
- Re: "Sorting" assignment
... algorithm such as tbe bubble sort should be given a free pass because ... I would tailor which algorithm to start with by how the student thinks ... If you only learn the beautiful side of programming, ... (comp.programming) - Re: puzzle
... >> Christopher Barber wrote: ... >> or understanding among programming professionals. ... > algorithm "close to" O. ... bubble sort, it is almost always acceptable to use an interchange sort: ... (comp.programming) - Re: Shocking mistake with comparitor function by Microsoft programmers!
... Well, I already got a very similar discussion with Pete, but ASSUMING the classic quick sort algorithm: ... The transitivity is not required by virtue of the partitions: those less than the pivot are in a partition which won't speak to those values that were greater to the pivot, since those are in another partition, and elements of different partitions would not be involved between themselves. ... The reflexivity rules are not required either since the pivot won't be compared, a second time (in the classic quick sort algorith). ... (microsoft.public.dotnet.languages.csharp) - Re: allowing my AI to dynamically change its own structure
... the only kind of sort you knew about. ... If you have a program with a goal of sorting lists of numbers, ... algorithm, ... from the very low level model you seem to prefer? ... (comp.ai) - Re: The ultimate luxury ?
... >>My definition in terms of imposing a linear order on a set is abstract ... >>and corresponds not to the algorithm of sorting, ... > that the CS dudes of today would not know what sort means. ... Jesse Hughes ... (sci.physics) |
|