Quick sort is a highly efficient, comparison-based, divide-and-conquer sorting algorithm. It works by selecting a "pivot" element from the list and partitioning the other elements into two sub-arrays: one with elements less than the pivot, and one with elements greater than the pivot. The sub-arrays are then recursively sorted.
Key Characteristics:
Time Complexity:
- Average case: O(n log n)
- Worst case: O(n²) (occurs when the pivot is poorly chosen, such as always being the smallest or largest element).
- Best case: O(n log n).
Space Complexity: O(log n) on average for the recursion stack (in-place sorting).
- Stability: It is not stable by default, meaning equal elements may not retain their relative order.
- Adaptivity: Quick sort is not adaptive.
#skinformativespot
#education
#datastructure
#quicksort
#sorting
#pivot
#pivotelement
#timecomplexity
#computerscience
#skinformativespot