Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

91
Views
Comparación de dígitos de clasificación Radix

Tengo una implementación del algoritmo LSD Radix Sort y me preguntaba cómo contar la cantidad de comparaciones de dígitos durante el procedimiento de clasificación. Sé que el algoritmo no se basa en la comparación, pero todavía hay algún tipo de comparación entre los dígitos de los elementos Integer que ordena el algoritmo. ¿Alguien puede señalar dónde se lleva a cabo la comparación?

¡Gracias!

LSDRadixOrdenar:

 public static void lsdRadixSort(int[] a) { final int BITS = 32; // each int is 32 bits final int R = 1 << BITS_PER_BYTE; // each bytes is between 0 and 255 final int MASK = R - 1; // 0xFF final int w = BITS / BITS_PER_BYTE; // each int is 4 bytes int n = a.length; int[] aux = new int[n]; for(int d = 0; d < w; d++) { // compute frequency counts int[] count = new int[R+1]; for(int i = 0; i < n; i++) { int c = (a[i] >> BITS_PER_BYTE*d) & MASK; count[c + 1]++; } // compute cumulates for(int r = 0; r < R; r++) { count[r+1] += count[r]; } //for most significant byte, 0x80-0xFF comes before 0x00-0x7F if(d == (w - 1)) { int shift1 = count[R] - count[R/2]; int shift2 = count[R/2]; for(int r = 0; r < R/2; r++) { count[r] += shift1; } for(int r = (R/2); r < R; r++) { count[r] -= shift2; } } // move data for(int i = 0; i < n; i++) { int c = (a[i] >> BITS_PER_BYTE*d) & MASK; aux[count[c]++] = a[i]; } // copy back for(int i = 0; i < n; i++) { a[i] = aux[i]; } } }
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Bueno, como bien dices, no hay comparaciones. La operación que más se acerca a eso es:

 count[c + 1]++;

donde c es un byte del entero. Cada número entero tiene 4 bytes, por lo que lo hace exactamente 4*n veces.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!