radix sort in c on floating points numbers -
okay have create radix sort both unsigned ints , floating point numbers. unsigned ints version works should, having little trouble getting work floating points values though. sorts values of array whole number value of floating point number doesn't sort based on decimal value. (ex. 36.65234 appear before 36.02311 if comes first in unsorted array) code segment bit manipulations , masking, pretty sure problem is.
/* loop create bin */ for(int i=0; i<n; i++){ temp_int = (((unsigned int)(list[i]))>>bitwise)&0xff; bin[temp_int] = bin[temp_int]+1; } /*for loop map */ (int i=0; i<256; i++) { map[i+1] = bin[i]+count; count = map[i+1]; } /* loop copy "sorted" values other array */ (int i=0; i<n; i++) { temp_int = (((unsigned int)(list[i]))>>bitwise)&0xff; int buf_loc = map[temp_int]; temp_arr[buf_loc] = list[i]; map[temp_int] = map[temp_int]+1; }
thanks in advance!
radix sort linear sorting algorithm. can applied floating point
values.
have @ :
Comments
Post a Comment