I've received a few more questions about the radix sorting assignment. Since they are probably of general interest I'll post my reply to everyone. > Should I make the size of each bin big enough to hold all of the numbers > for my particular problem size? That is fine for debugging but is not really what I intended for the final solution. If the values for any digit position were distributed evenly across all of the possible values then each bin would need to hold, for example, 1/256th of the total numbers if you use my default defines. However, the random numbers will not behave so perfectly and some bins will need to contain more numbers than other bins. That is the reason for having both the size_bin[] and n_in_bin[] arrays so you can do the bookkeeping according to the actual distribution. A good strategy is to start off with bins that can hold perhaps 1/2 or 3/4th of the average expected number of values and then reallocate as n_in_bin[] exceeds size_bin[]. This brings up something that I did not get to in class. We've already seen how to use malloc() to allocate memory space and some of you know that you can use free() to give memory back when you no longer need it. Most of you probably have not used realloc(). Realloc lets you change your mind about how much memory you need by changing the size of an already allocated block of memory. Realloc needs 2 arguments. The first one is a pointer to memory that has already been allocated and the 2nd argument says how big new new memory allocation should be. For example unsigned char *cp; cp = malloc(20); cp = realloc(cp, 1000); would initially allocate 20 bytes but the realloc would increase it to 1000. It is VERY important to realize that you can only realloc something that has already been malloced. You may realloc more than once if you find that you need even more memory .... cp = realloc(cp, 3000); In our assignment when a bin fills up you would use realloc to increase its size and keep proper track of the corresponding new size_bin[] value. Realize that the reallocated memory may be in a different location from the original memory. In that case realloc will copy all of the contents from the old to the new location. This is expensive so you don't want to realloc on a one by one basis. Rather, you want to realloc according to some reasonable incriment like an additional 20% or whatever so that the average impact is not too bad. For more information look at the online manual page by doing ... man realloc > After reviewing your code I have a good idea about the masking process, > but I am a little confused on processing the array of numbers as opposed > to 1 number like you did. In your example you just chomped the end of the > number every time you masked it and that is how you ran your loop until > the number was no longer. Yes, it is true that my masking.c example simply worked progressively off of the right end of the value n in, for example, for( ; n; n >>= 1) printf("binary digit is %d\n", n & 1); However we don't have to work off of just the right end. Consider ... for(shift = 31; shift >= 0; shift--) if((n >> shift) & 1) putchar('1'); else putchar('0'); which operates from left to right and never modifies n. > I am confused on how many radixes to loop? I can't seem to figure out a > test condition without changing the number and I'm sure that would something > that is unneeded to do every time you wanted to test 1 number at a certain > radix position. I wanted to know if you had any suggestions on this? You won't loop over different radixes but will need to loop across all of the digit positions in what ever radix you select. In the template lines ... #define BITS 8 /* specify the radix by number of bits */ #define RADIX (1<