{
  "schema_version": "1.0",
  "codex": "thecodex.expert/coding",
  "type": "algorithm",
  "slug": "algorithms/sorting/quicksort",
  "name": "Quicksort",
  "section": "Algorithms",
  "canonical_definition": "Quicksort is a comparison-based in-place sorting algorithm that partitions an array around a chosen pivot element \u2014 placing all smaller elements before the pivot and all larger after \u2014 then recursively sorts each partition, achieving Theta(n log n) expected time with O(log n) space.",
  "complexity": {
    "best": "Theta(n log n)",
    "average": "Theta(n log n)",
    "worst": "Theta(n^2)",
    "space": "O(log n)",
    "stability": "not stable"
  },
  "confidence": "high",
  "last_verified": "2026-06-01",
  "url": "https://thecodex.expert/coding/algorithms/sorting/quicksort/",
  "concept_relationship": {
    "requires_first": [
      "algorithms/sorting",
      "concepts/recursion"
    ],
    "enables": [
      "algorithms/searching"
    ],
    "commonly_confused_with": [
      "not always faster than merge sort",
      "not stable",
      "O(log n) stack can overflow in degenerate cases"
    ]
  },
  "sources": [
    {
      "num": 1,
      "citation": "Hoare 1962 Computer Journal 5(1)",
      "tier": 1
    },
    {
      "num": 2,
      "citation": "CLRS 4th ed. \u00a77",
      "tier": 1
    },
    {
      "num": 3,
      "citation": "Musser 1997 SPE 27(8) Introsort",
      "tier": 1
    },
    {
      "num": 4,
      "citation": "Yaroslavskiy 2009 dual-pivot OpenJDK",
      "tier": 1
    }
  ]
}