Counting Sort optimization
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Aptitud para principiantes
- 30/100
- Tipo de issue
- Refactorización
- Claridad
- Necesita aclaración
- Estado de actividad
- Estancado
- Stack tecnológico
- javascript
- Área
- data
Línea de trabajo
Start by locating the Counting Sort implementation and comparing it with the linked TypeScript example. Before changing it, establish whether the proposed one-pass lookup optimization preserves sorting behavior and define tests or measurements that demonstrate correctness and the claimed memory and performance improvement.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Hi devs!
On the very beginning I want to appreciate your work here, I think it is fantastic and gives a lot of addition to developers knowledge!
But this ticket I want to open to point potential optimization of Counting Sort algorithm.
In the implementation there are is loop by all array elements to find smallest and biggest.
Next step is creating counting array of size dependent on smallest and biggest.
And in next step there is one more iteration by all elements to set up counting array.
I am wondering if there could be optimization applied and make all of those in just 1 iteration, moreover there could be used lookup instead of array.
Lets consider this example of array to be sorted:
const arrayToSort = [1, 1, 10000, 1, 1, 10000, 10000, 1, 1];
When switched to lookup object instead of array we will have small object:
{"1": 6, "10000": 3}
When using array it will be bigger:
[0, 6, 0, 0, 0, 0, ....(a lot of zeros), 10000]
So finally we could find biggest, smallest and set lookup values in 1 iteration and having lesser memory used.
I prepared example of that:
*The next difference is that I am preparing algorithm which is mutating original array, but it can be applied here too:
example
Please reply if this make sense to you, I would be more than happy to make MR to your great work!
- Lenguaje dominante
- JavaScript
- Estrellas
- 197k
- Forks
- 31k
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de trekhleb/javascript-algorithms
-
BinarySearchTreeNode removing Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
trekhleb/javascript-algorithms#2102 · 1 comentario ·
-
Dificultad 4/5 3-5 días Aptitud para principiantes 25/100
trekhleb/javascript-algorithms#2085 · 6 comentarios · 1 reacción ·
-
LinkedList methods. Abierto
Dificultad 3/5 1-2 días Aptitud para principiantes 35/100
trekhleb/javascript-algorithms#2065 · 1 comentario ·
-
Dificultad 3/5 1-2 días Aptitud para principiantes 55/100
trekhleb/javascript-algorithms#2057 · 1 comentario ·
-
Dificultad 3/5 1-2 días Aptitud para principiantes 35/100
trekhleb/javascript-algorithms#2056 ·
Todos los issues de trekhleb/javascript-algorithms
Issues similares
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
avniproject/avni-client#2135 ·
-
enhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
babalae/bettergi-scripts-list#3674 ·
-
A-Release-Notes C-Editing D-Modest S-Ready-For-Implementation
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
bevyengine/bevy-website#2595 ·
-
ecosystem wording
Dificultad 1/5 Menos de una hora Aptitud para principiantes 90/100
matrix-org/matrix.org#3649 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
vadimdemedes/ink#1029 ·