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
#265 2 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

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.

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

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Ö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

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.