radix

Radix sort implemented in c++ for string [closed]

ぃ、小莉子 提交于 2019-12-23 06:39:20
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 4 years ago . i just need radix sort implementation in c++ language which works for strings i already have the one which works for normal integers vector < vector < int> > blocks[7]; void radixSort(int rsarr[],int length){ int index; vector<int> helper; vector< vector<int> > helper2; for(int e

Swift. Get binary string from an integer

若如初见. 提交于 2019-12-22 16:29:33
问题 I have binary 0000010 which is represented as an array of ints. From this binary I get an Integer : let number = Int32([0, 0, 0, 0, 0, 1, 0].reduce(0, combine: {$0*2 + $1})) // number = 2 but when I want to inverse operation to get a String : let binaryString = String(2, radix: 2) // binaryString = "10" So seems radix cuts some bits if they are 0, how to return 5 more zeros? 回答1: let binaryString = String(2, radix: 2) let other = String(count: 8 - binaryString.characters.count, repeatedValue:

Radix sort using bitwise operations

ε祈祈猫儿з 提交于 2019-12-20 15:37:40
问题 First of all this is homework , and I found another topic talking about the same subject but there was no answer. Here is the problem: Sorting by bit based on the assumption that the values ​​to be sorted are integers coded B bits (and therefore between 0 and 2B-1). The main problem is how to make this kind of sort. Should I convert each integer to bits and compare them? Please do not give me the solution just a hint or an explanation of how to do it. Thanks for your help ! [EDIT] I found

Base-N encoding of a byte array

社会主义新天地 提交于 2019-12-17 19:52:37
问题 A couple of days ago I came across this CodeReview for Base-36 encoding a byte array. However, the answers that followed didn't touch on decoding back into a byte array, or possibly reusing the answer to perform encodings of different bases (radix). The answer for the linked question uses BigInteger. So as far as implementation goes, the base and its digits could be parametrized. The problem with BigInteger though, is that we're treating our input as an assumed integer. However, our input, a

How to print character array in reverse order of C program

自古美人都是妖i 提交于 2019-12-13 07:41:30
问题 #include <stdlib.h> #include <stdio.h> #define SIZE 25 int main (void) { int d, b, c; printf(" Enter an integer and press 'enter':\n"); scanf("%d" , &d); printf(" Enter the desired base and press 'enter':\n"); scanf("%d" , &b); if (b < 2) { printf(" Your base is to low! \n") } else { while (d != 0) { int radix; radix = d % b; d = d / b; char basechars[] = "0123456789ABCDEF"; printf("%c" , basechards[radix]); } } return 0; } This Program prompts the user for a decimal and a base to convert

Radix Sort Floating Data

a 夏天 提交于 2019-12-12 16:25:04
问题 How does radix sorts float data? for example 12.4, 45.13 etc. would it read the right side of the decimal point first?or the left side of the decimal point first?And then if it read the right side of the decimal point, how would it treat the numbers, would it first read the rightmost first? 回答1: See this page of a discussion of it. http://codercorner.com/RadixSortRevisited.htm Basically, computers store the floating point in a particular format. They do not write it out as 45.13. As a result,

FormatException: Invalid radix-10 number

允我心安 提交于 2019-12-12 01:18:14
问题 I'm trying to receive a get request using Flutter and HttpClient. This is complete code in what I'm trying to accomplish. getSuggest() async { try { var httpClient = new HttpClient(); var uri = new Uri.http( 'http://autocomplete.geocoder.api.here.com', '/6.2/suggest.json', { 'app_id': 'APP_ID', 'app_code': 'APP_CODE', 'query': '123 Main Street', 'country': 'USA', 'language': 'en', }); var request = await httpClient.getUrl(uri); var response = await request.close(); var responseBody = await

Can't get the radix sort algorithm to work in C++

╄→尐↘猪︶ㄣ 提交于 2019-12-11 17:40:19
问题 Given n 32 bit integers (assume that they are positive), you want to sort them by first looking at the most significant shift in total bits and recursively sorting each bucket that is created by the sorted integers on those bits. So if shift is 2, then you will first look at the two most significant bits in each 32 bit integer and then apply counting sort. Finally, from the groups that you will get, you recurse on each group and start sorting the numbers of each group by looking at the third

How can I convert a very large integer from one base/radix to another using FFT?

与世无争的帅哥 提交于 2019-12-11 02:37:50
问题 Are there known algorithms which will take a big integer with n digits encoded in one base/radix and convert it to another arbitrary base? (Let's say from base 7 to base 19.) n can be really big, like more than 100 000 digits, so I am looking for something better than O( n 2 ) run time. I have seen some algorithms that can multiply two huge integers using the Fast Fourier Transform (FFT), with the theoretical complexity of O( n log n ), where n is the number of digits, so I wonder if

Radix Sort: Descending

杀马特。学长 韩版系。学妹 提交于 2019-12-08 04:05:10
问题 Here is my RadixSort function (ascending): void RadixSort (int a[], int n) { int i, m=0, exp=1, b[MAX]; for (i=0; i<n; i++) { if (a[i]>m) m=a[i]; } while (m/exp>0) { int bucket[10]={0}; for (i=0; i<n; i++) bucket[a[i]/exp%10]++; for (i=1; i<10; i++) bucket[i]+=bucket[i-1]; for (i=n-1; i>=0; i--) b[--bucket[a[i]/exp%10]]=a[i]; for (i=0; i<n;i++){ a[i]=b[i]; } exp*=10; } } I'm try to change this to a descending sort by replacing for (i=0; i<n;i++) { a[i]=b[i]; } with for (i=0; i<n;i++) { a[i]=b