# Radix sort algorithm implementation in C

## Radix sort in an intuitive non-comparative integer title sorting algorithm Radix sort puts the elements in order by comparing the individual digits of the numbers which share the same significant position and value. Radix sort processes the digits either by Least Significant Digit (LSD) method or by Most Significant Digit (MSD) method.

#### The algorithm of Radix sort follows the following pattern :

• Receive an unsorted array of integer, often referred/represent a key.
• Iterate from most to least (or least to most) significant digits.
• Each iteration sort all of the values of the current significant digit the array.
* A key is symbolized as an integer value, which can be associated with other data, such as birth date, location etc.

#### There are two classification of Radix sorting :

LSD radix sorts typically use short keys come before longer keys, and keys of the same length are sorted lexicographically.This coincides with the normal order of integer representations, A sequence as “ 2,9,3,4,7,5,6,1,8,10”and after sorting the sequence 1, 2, 3, 4, 5, 6, 7, 8, 9, 10.And for words, A sequence such as "b, c, d, e, f, g, h, i, ba"would be lexicographically sorted as "ba, b, c, d, e, f, g, h, i".

MSD radix sorts use lexicographic order, which is suitable for sorting strings, such as words, or fixed-length integer representations. A sequence such as "b, c, d, e, f, g, h, i, ba" would be lexicographically sorted as "b, ba, c, d, e, f, g, h, i". And for variable –length integer representation, A sequence as “ 2,9,3,4,7,5,6,1,8,10”and after sorting the sequence 1,10, 2, 3, 4, 5, 6, 7, 8, 9 .

Suppose we have 9 numbers:
493   812   715   710   195   437   582   340   385
After Sorting it should be look like this:
195   340   385   437   493   582   710   715   812
We should start sorting by comparing and ordering the one's digits:

Notice that the numbers were added onto the list in the order that they were found, which is why the numbers appear to be unsorted in each of the sub lists above. Now, we gather the sub lists (in order from the 0 sub list to the 9 sub list) into the main list again:
340   710   812   582   493   715   195   385   437
Note: The order in which we divide and reassemble the list is extremely important, as this is one of the foundations of this algorithm.
Now, the sub lists are created again, this time based on the ten's digit:

Now the sub lists are gathered in order from 0 to 9:
710   812   715   437   340   582   385   493   195
Finally, the sub lists are created according to the hundred's digit:

At last, the list is gathered up again:
195   340   385   437   493   582   710   715   812

The C Code using LSD Radix sort Algorithm is below:

Radix Sort is very simple, and a computer can do it fast. When it is programmed properly, Radix Sort is in fact one of the fastest sorting algorithms for numbers or strings of letters. But sometimes it does not sort in place. Running Time of Radix sort is:  O (d (n+k)), where n is the number of elements and k is the number of bits per element and d is digit.

#### Introduction to algorithm,3rd edition                      Programming in ANSI C by Balagurusamy

Radix sort algorithm implementation in C programming. Radix sort in an intuitive non-comparative integer title sorting algorithm Radix sort puts the elements in order by comparing the individual digits of the numbers which share the same significant position and value. Radix sort processes the digits either by Least Significant Digit (LSD) method or by Most Significant Digit (MSD) method.The algorithm of Radix sort follows the following pattern. Radix sort algorithm implementation in C code.
{"ft_lang_label":"__label__en","ft_lang_prob":0.8844131,"math_prob":0.9564196,"size":2485,"snap":"2019-51-2020-05","text_gpt3_token_len":659,"char_repetition_ratio":0.13099557,"word_repetition_ratio":0.03501094,"special_character_ratio":0.294165,"punctuation_ratio":0.14233577,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.98343396,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2019-12-07T22:28:00Z\",\"WARC-Record-ID\":\"<urn:uuid:be66dbef-17b9-437b-854b-69f1ad038b9a>\",\"Content-Length\":\"569750\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:4e6f736a-9813-452f-a42e-87fa99837c9c>\",\"WARC-Concurrent-To\":\"<urn:uuid:9ca47316-eece-4ef1-8208-fe0970d42387>\",\"WARC-IP-Address\":\"172.217.13.83\",\"WARC-Target-URI\":\"https://www.programmingboss.com/2015/03/radix-sort-algorithm-implementation-in-c.html\",\"WARC-Payload-Digest\":\"sha1:REYVI4OCKKPJU5PC3SNC5CRSUA2OIMQG\",\"WARC-Block-Digest\":\"sha1:LED5STDC7ECIQVBGFX2SCX5VIRBHSOSG\",\"WARC-Identified-Payload-Type\":\"application/xhtml+xml\",\"warc_filename\":\"/cc_download/warc_2019/CC-MAIN-2019-51/CC-MAIN-2019-51_segments_1575540502120.37_warc_CC-MAIN-20191207210620-20191207234620-00059.warc.gz\"}"}