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 @@ -53,7 +53,18 @@ namespace quick_sort {
53
53
* @param low first point of the array (starting index)
54
54
* @param high last point of the array (ending index)
55
55
* @returns index of the smaller element
56
- */
56
+ *
57
+ * Time Complexity
58
+ * best case, average Case: O(nlog(n))
59
+ * Worst Case: O(n^2) (Worst case occur when the partition
60
+ * is consistently unbalanced.)
61
+
62
+ * Space Complexity
63
+ * average Case: O(log(n))
64
+ * Worst Case: O(n)
65
+ * It's space complexity is due to the recursive function calls and partitioning process.
66
+ */
67
+
57
68
template <typename T>
58
69
int partition (std::vector<T> *arr, const int &low, const int &high) {
59
70
T pivot = (*arr)[high]; // taking the last element as pivot
You can’t perform that action at this time.
0 commit comments