Description
Divide-and-conquer in-place sort. Pick pivot (e.g. last element). Partition: elements < pivot go left, > pivot go right. Recursively quicksort left and right partitions. Average O(n log n); worst O(n²) if pivot bad. Not stable.
Source: Wikipedia
Algorithm Flowchart
graph TD
A1["Array A lo hi"]
D1{"Base case?\nlo ge hi"}
B1["Pick pivot p\nPartition A around p"]
C1["Quicksort A lo p-1\nQuicksort A p+1 hi"]
F1["Return in-place sorted"]
A1 --> D1
D1 -->|Yes| F1
D1 -->|No| B1
B1 --> C1
C1 --> F1
classDef red fill:#ff6b6b,color:#fff,stroke:#c0392b
classDef yellow fill:#ffd43b,color:#000,stroke:#f59f00
classDef green fill:#51cf66,color:#fff,stroke:#40c057
classDef lightblue fill:#74c0fc,color:#fff,stroke:#4dabf7
classDef violet fill:#b197fc,color:#fff,stroke:#9775fa
classDef lavender fill:#e6e6fa,color:#333,stroke:#b19cd9
class A1 red
class B1 yellow
class C1 green
class F1 violet
class D1 lavender
Color Scheme (GLMP 6-Color)
Red
Triggers & Inputs
Triggers & Inputs
Yellow
Structures & Objects
Structures & Objects
Green
Processing & Operations
Processing & Operations
Light Blue
Intermediates & States
Intermediates & States
Violet
Products & Outputs
Products & Outputs
Lavender
Decision diamonds
Decision diamonds
Process Statistics
- Nodes: 5
- Edges: 5
- OR gates: 1
- Loops: 0
- AND gates: 1
- Complexity: O(n log n) avg, O(n²) worst
Keywords
- quicksort
- divide and conquer
- sorting
- partition