trekhleb / trekhleb/javascript-algorithms
QuickSort : Instead of taking pivot as 1st element, we should take the pivot as last element, due to time complexity
Offen
Dieses Issue hat noch niemand übernommen.
enhancement
- Vorherrschende Sprache
- JavaScript
- Sterne
- 197k
- Forks
- 31k
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
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
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
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.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- javascript
- Bereich
- data
- Issue-Typ
- Refactoring
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100