You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When running a bucket sort program using UnitTestBotCpp, which is not a complex program, I am unable to generate the corresponding test cases. Why is this happening?
Here is the code:
void bucketSort(std::vector& arr) {
int n = arr.size();
int maxVal = *std::max_element(arr.begin(), arr.end());
int minVal = *std::min_element(arr.begin(), arr.end());
int bucketSize = (maxVal - minVal) / n + 1;
std::vector<std::vector<int>> buckets(n);
for (int num : arr) {
int bucketIndex = (num - minVal) / bucketSize;
buckets[bucketIndex].push_back(num);
}
for (std::vector<int>& bucket : buckets) {
std::sort(bucket.begin(), bucket.end());
}
int index = 0;
for (std::vector<int>& bucket : buckets) {
for (int num : bucket) {
arr[index++] = num;
}
}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
When running a bucket sort program using UnitTestBotCpp, which is not a complex program, I am unable to generate the corresponding test cases. Why is this happening?
Here is the code:
void bucketSort(std::vector& arr) {
int n = arr.size();
int maxVal = *std::max_element(arr.begin(), arr.end());
int minVal = *std::min_element(arr.begin(), arr.end());
int bucketSize = (maxVal - minVal) / n + 1;
}
Beta Was this translation helpful? Give feedback.
All reactions