Hi MJ,
The negative pair value can be workarounded by normalizing the
pair to be in the [0,MAX_INT] range.
This can be achieved by adding MAX_INT/2 to the pair before
addressing the one bit in the bit map.
unsigned long pair;
long X;
for i=0 to N
pair = X - array[i] +
No matter the array can hold other elements or not, you can always use
auxiliary memory space to make it store more than 01, suppose it is a M*N
array,
initializing the auxiliary space will cost O(m*n).
and the algorithm can be described as follow:
for(int i=0; in; ++i)
for(int
The below algorithm cost 3*O(m*n)+NumberOfInitialZeros*( O(m)+o(n) )
=
No matter the array can hold other elements or not, you can
Hi again
On Nov 24, 8:15 pm, Sherry [EMAIL PROTECTED] wrote:
.. But how
could I predict the time taken for these sorts when I know n?
Now I understand where you are coming from.
here is my table for the bubble sort:
Time in milliseconds:
# of # Random Half-Sorted
Here I come up with a better solution.
first I need 2 auxiliary link list, named Rows and Cols, in where the
contains zero column/row is stored.
then I scan the matrix, when finding an '0', I just insert the row and
column of this '0' into the Rows and Cols lists.
then after the first scan,
Hi Kumar,
if the array is a bit array, my solution is first copy the entire
array to the auxiliary memory, where -1 can be stored, then do the
other work.
and there's another better solution I memtioned on the above post,
it dosen't require the array to store -1.
Best Regards,
James