Skip to content

QuickSort : Instead of taking pivot as 1st element, we should take the pivot as last element, due to time complexity #265

Open
@talentedandrew

Description

@talentedandrew

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions