02-26-2008 12:38 AM
02-26-2008 01:00 AM
02-26-2008 01:24 AM - edited 02-26-2008 01:28 AM
There is nothing wrong with loops, the main performance issue with this kind of problems is the fact thay the size of your array changes with every operation. This causes constant expensive memory reallocations if not done right..
Is the final array size constant?
The most efficient way would probably be to allocate an array sized to an upper limit, then conditionally fill it up with valid data, e.g. doing the comparison, keeping track of the insert point in a shift register, and conditionally replace elements with valid data. The key word is "in place".
You lost me right there! Can you be a bit more specific? I have no idea what you are saying here.
Parny wrote:
... the array is static(already having some values), and using "for loops".
02-26-2008 07:19 PM
02-27-2008 02:20 AM
02-27-2008 10:30 AM - edited 02-27-2008 10:31 AM
Parny wrote:
The final array size is not same always, so its not constant.