Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

147
Vistas
Pigeonhole Sort. What would be the invariant of the outermost iteration?

here is my code

<script>
 
// JavaScript program to implement
// Pigeonhole Sort
 
function pigeonhole_sort(arr, n)
{
    let min = arr[0];
    let max = arr[0];
    let range, i, j, index;
   
    for(let a = 0; a < n; a++)
    {
        if(arr[a] > max)
            max = arr[a];
        if(arr[a] < min)
            min = arr[a];
    }
   
    range = max - min + 1;
    let phole = [];
       
    for(i = 0; i < n; i++)
    phole[i] = 0;
   
    for(i = 0; i < n; i++)
        phole[arr[i] - min]++;
   
       
    index = 0;
   
    for(j = 0; j < range; j++)
        while(phole[j] --> 0)
            arr[index++] = j + min;
   
}
 
// Driver Code
 
    let arr = [8, 3, 2, 7,
                 4, 6, 8];
   
    document.write("Sorted order is : ");
   
    pigeonhole_sort(arr,arr.length);
       
    for(let i = 0 ; i < arr.length ; i++)
        document.write(arr[i] + " ");
     
    // This code is contributed by target_2.
</script>

This is the code and the Pigeonhole sorting method is already implemented in it, what I need to know is what is the corresponding iteration invariant for this code or good for the Pigeonhole sorting code

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda