We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 3f6876f commit da53b26Copy full SHA for da53b26
sorting/quick_sort.cpp
@@ -54,7 +54,18 @@ namespace quick_sort {
54
* @param low first point of the array (starting index)
55
* @param high last point of the array (ending index)
56
* @returns index of the smaller element
57
- */
+ *
58
+ * ### Time Complexity
59
+ * best case, average Case: O(nlog(n))
60
+ * Worst Case: O(n^2) (Worst case occur when the partition
61
+ * is consistently unbalanced.)
62
+
63
+ * ### Space Complexity
64
+ * average Case: O(log(n))
65
+ * Worst Case: O(n)
66
+ * It's space complexity is due to the recursive function calls and partitioning process.
67
+ */
68
69
template <typename T>
70
int partition(std::vector<T> *arr, const int &low, const int &high) {
71
T pivot = (*arr)[high]; // taking the last element as pivot
0 commit comments