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
#265 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

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.

  1. QuickSort › should do stable sorting
  2. QuickSort › should visit NOT SORTED array element specified number of times

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. 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

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.