GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — javascript-algorithms/src/algorithms/sorting/quick-sort at master · codameio/javascript-algorithms

Expand file tree

/

quick-sort

/
Copy path

Directory actions

More options

More options

Directory actions

More options

More options

Latest commit

 

History

History
History
 
 
/

quick-sort

/
Copy path

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
__test__
__test__
 
 
QuickSort.js
QuickSort.js
 
 
QuickSortInPlace.js
QuickSortInPlace.js
 
 
README.md
README.md
 
 
README.pt-BR.md
README.pt-BR.md
 
 
README.zh-CN.md
README.zh-CN.md
 
 

README.md

Outline

Quicksort

Read this in other languages: Português, 简体中文

Quicksort is a divide and conquer algorithm. Quicksort first divides a large array into two smaller sub-arrays: the low elements and the high elements. Quicksort can then recursively sort the sub-arrays

The steps are:

  1. Pick an element, called a pivot, from the array.
  2. Partitioning: reorder the array so that all elements with values less than the pivot come before the pivot, while all elements with values greater than the pivot come after it (equal values can go either way). After this partitioning, the pivot is in its final position. This is called the partition operation.
  3. Recursively apply the above steps to the sub-array of elements with smaller values and separately to the sub-array of elements with greater values.

Animated visualization of the quicksort algorithm. The horizontal lines are pivot values.

Quicksort

Complexity

Name Best Average Worst Memory Stable Comments
Quick sort n log(n) n log(n) n2 log(n) No Quicksort is usually done in-place with O(log(n)) stack space

References

  • Wikipedia
  • YouTube
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.