Skip to content

Commit f238dd1

Browse files
Apply suggestions from code review
Co-authored-by: realstealthninja <[email protected]>
1 parent 1e363ee commit f238dd1

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

sorting/tim_sort.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,13 @@ void printArray(int arr[], int n) {
9191
std::cout << std::endl;
9292
}
9393

94-
void test(int n) {
95-
int *arr = new int[n];
94+
/**
95+
* @brief self-test implementation
96+
* @returns void
97+
*/
98+
void test() {
99+
// Case: array of length 65
100+
int arr[65];
96101

97102
std::iota(arr, arr + n, 0);
98103
std::reverse(arr, arr + n);
@@ -101,12 +106,11 @@ void test(int n) {
101106
timSort(arr, n);
102107
assert(std::is_sorted(arr, arr + n));
103108

104-
delete[] arr;
105109
}
106110

107111
// Driver program to test above function
108112
int main() {
109-
test(65);
113+
tests();
110114

111115
int arr[] = {5, 21, 7, 23, 19};
112116
int n = sizeof(arr) / sizeof(arr[0]);

0 commit comments

Comments
 (0)