A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://TheAlgorithms.github.io/C-Plus-Plus/d8/d61/radix__sort2_8cpp_source.html below:

TheAlgorithms/C++: sorting/radix_sort2.cpp Source File

Go to the documentation of this file. 53 const

std::vector<uint64_t>& ar) {

55

std::vector<uint32_t> position(10, 0);

56 for

(

int

i = 0; i < n; ++i) {

57

position[(ar[i] / cur_digit) %

61 for

(

int

i = 0; i < 10; ++i) {

66

std::vector<uint64_t> temp(n);

67 for

(

int

i = 0; i < n; ++i) {

68

temp[position[(ar[i] / cur_digit) % 10]] =

71

position[(ar[i] / cur_digit) %

82

std::vector<uint64_t>

radix

(

const

std::vector<uint64_t>& ar) {

84

*max_element(ar.begin(), ar.end());

85

std::vector<uint64_t> temp = ar;

86 for

(

int

i = 1; max_ele / i > 0;

91 for

(uint64_t i : temp) {

92

std::cout << i <<

" "

;

106

std::vector<uint64_t> ar1 = {432, 234, 143, 332, 123};

108

assert(std::is_sorted(ar1.begin(), ar1.end()));

110

std::vector<uint64_t> ar2 = {213, 3214, 123, 111, 112, 142,

111

133, 132, 32, 12, 113};

113

assert(std::is_sorted(ar2.begin(), ar2.end()));

Functions for Radix sort algorithm.

static void tests()

Function to test the above algorithm.

std::vector< uint64_t > step_ith(uint16_t cur_digit, const std::vector< uint64_t > &ar)

Function to sort vector according to current digit using stable sorting.

std::vector< uint64_t > radix(const std::vector< uint64_t > &ar)

Function to sort vector digit by digit.

int main()

Main function.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4