File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -54,7 +54,18 @@ namespace quick_sort {
54
54
* @param low first point of the array (starting index)
55
55
* @param high last point of the array (ending index)
56
56
* @returns index of the smaller element
57
- */
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
+
58
69
template <typename T>
59
70
int partition (std::vector<T> *arr, const int &low, const int &high) {
60
71
T pivot = (*arr)[high]; // taking the last element as pivot
You can’t perform that action at this time.
0 commit comments