15,918,967 members
Home / Discussions / Algorithms

# Algorithms

 Re: Distributing (different sized) objects Alan Balkany16-Jul-10 6:06 Alan Balkany 16-Jul-10 6:06
 Re: Distributing (different sized) objects Wjousts20-Jul-10 3:30 Wjousts 20-Jul-10 3:30
 Re: Distributing (different sized) objects Luc Pattyn20-Jul-10 8:11 Luc Pattyn 20-Jul-10 8:11
 Re: Distributing (different sized) objects Wjousts20-Jul-10 9:14 Wjousts 20-Jul-10 9:14
 Re: Distributing (different sized) objects Luc Pattyn20-Jul-10 9:38 Luc Pattyn 20-Jul-10 9:38
 Getting all combinations of N sets of objects iteratively gantww11-Jul-10 15:58 gantww 11-Jul-10 15:58
 Re: Getting all combinations of N sets of objects iteratively Alan Balkany15-Jul-10 3:55 Alan Balkany 15-Jul-10 3:55
 My sorting algorithm AksharRoop6-Jul-10 4:53 AksharRoop 6-Jul-10 4:53
 I have a list of values in single dimensional vector/array as follow: `{([point0, value0], [point1, value1], ... , [pointx, valuex]), ([pointx+1, valuex+1], [pointx+2, valuex+2], ... , [pointy, valuey]), ([pointy+1, valuey+1], [pointy+2, valuey+2], ... , [pointz, valuez])}` [at first it may look like weird how this is single dimentional array; but yes it is ] `{point0,value0,point1,value1,...,pointx,valuex}` Here i know how values are structured in an input array. I just need to implement best sorting technique for this. Requirement is to sort each block based on point value(i.e. sort point0,value0 to pointx,valuex). I have information about number of elements in each block (which will be consistent for all blocks). I can simply write something like: ```
// blockSize is given
// totalBlocks size is given
// setOfValues is given (to be sorted)``` ```for(int blockIndex = 0 ; blockIndex < totalBlocks; ++blockIndex)
{
for(int i = blockSize * blockIndex; i < blockSize*(blockIndex + 1); i = i + 2)
{
for(int j = blockSize * blockIndex; j < blockSize*(blockIndex + 1); j = j + 2)
{
if (setOfValues[i] < setOfValues[j])
{
int temp = setOfValues[i];
setOfValues[i] = setOfValues[j];
setOfValues[j] = temp;

temp = setOfValues[i+1];
setOfValues[i+1] = setOfValues[j+1];
setOfValues[j+1] = temp;
}
}
}
}``` Time required for this algorithm is very huge: O(totalBlocks * blockSize^2) I am thinking of writing this in better way. Any help would be great! Thanks, AksharRoop
 Re: My sorting algorithm Luc Pattyn6-Jul-10 5:20 Luc Pattyn 6-Jul-10 5:20
 Re: My sorting algorithm AksharRoop6-Jul-10 5:24 AksharRoop 6-Jul-10 5:24
 Re: My sorting algorithm RugbyLeague6-Jul-10 22:41 RugbyLeague 6-Jul-10 22:41
 Re: My sorting algorithm molesworth7-Jul-10 1:33 molesworth 7-Jul-10 1:33
 Re: My sorting algorithm RugbyLeague7-Jul-10 2:37 RugbyLeague 7-Jul-10 2:37
 Counting set bits in bitmap Tadeusz Westawic24-Jun-10 4:51 Tadeusz Westawic 24-Jun-10 4:51
 Re: Counting set bits in bitmap [modified] harold aptroot24-Jun-10 5:14 harold aptroot 24-Jun-10 5:14
 Re: Counting set bits in bitmap [modified] Tadeusz Westawic24-Jun-10 6:07 Tadeusz Westawic 24-Jun-10 6:07
 Re: Counting set bits in bitmap harold aptroot24-Jun-10 6:19 harold aptroot 24-Jun-10 6:19
 Re: Counting set bits in bitmap harold aptroot24-Jun-10 7:01 harold aptroot 24-Jun-10 7:01
 Re: Counting set bits in bitmap Tadeusz Westawic24-Jun-10 7:46 Tadeusz Westawic 24-Jun-10 7:46
 Re: Counting set bits in bitmap Luc Pattyn24-Jun-10 8:06 Luc Pattyn 24-Jun-10 8:06
 Re: Counting set bits in bitmap Tadeusz Westawic24-Jun-10 10:27 Tadeusz Westawic 24-Jun-10 10:27
 Re: Counting set bits in bitmap [modified] Luc Pattyn24-Jun-10 11:00 Luc Pattyn 24-Jun-10 11:00
 Re: Counting set bits in bitmap harold aptroot24-Jun-10 8:07 harold aptroot 24-Jun-10 8:07
 Re: swimming adder Luc Pattyn24-Jun-10 8:32 Luc Pattyn 24-Jun-10 8:32
 Re: Counting set bits in bitmap [modified] Tadeusz Westawic24-Jun-10 9:04 Tadeusz Westawic 24-Jun-10 9:04
 Last Visit: 31-Dec-99 18:00     Last Update: 17-Jun-24 22:08 Refresh ᐊ Prev1...114115116117118119120121122123 Next ᐅ