trekhleb / trekhleb/javascript-algorithms
QuickSort : Instead of taking pivot as 1st element, we should take the pivot as last element, due to time complexity
Aperta
Nessuno ha ancora preso questa issue.
enhancement
- Lingua principale
- JavaScript
- Stelle
- 197k
- Fork
- 31k
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
Instead of this
const pivotElement = array.shift(); // O(n)
we should use
const pivotElement = array.pop(); // O(1)
When taking the pivot as last element 2 test cases are failing.
- QuickSort › should do stable sorting
- QuickSort › should visit NOT SORTED array element specified number of times
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Start at the QuickSort implementation where the pivot is selected, then run the two named failing tests: stable sorting and visiting unsorted elements the specified number of times. Done means the pivot change improves the stated complexity without breaking either test.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- javascript
- Ambito
- data
- Tipo di issue
- Refactoring
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100