mirror of
https://github.com/TheAlgorithms/C.git
synced 2026-02-14 13:54:36 +00:00
[FEATURE] #203
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @Ujwal200707 on GitHub (Nov 2, 2025).
Detailed description
in your bubble sort.c
Your test() function generates random numbers. If an assertion fails, it’s hard to debug because the array changes every run.
Context
The test function generates a new random array each time it runs, so if a bug occurs, the failing input changes on every run. This makes debugging and reproducing failures difficult because the array is nondeterministic.
Possible implementation
Solution:
Add a deterministic test array with known numbers.
Optionally, print the array before and after sorting to debug.
int test_arr[] = {5, 1, 4, 2, 8};
bubbleSort(test_arr, 5);
for (int i = 0; i < 4; i++)
assert(test_arr[i] <= test_arr[i + 1]);
Additional information
Relying solely on random data can hide edge cases, such as already sorted arrays, reverse-sorted arrays, or arrays with duplicate values, which may not be generated by rand().
Random tests do not guarantee full coverage of possible scenarios that could break the algorithm.
Without printing the array, it’s impossible to know what input caused a failure, making debugging harder.
Using a deterministic array alongside random tests ensures reproducibility and better verification of the sorting logic.
@Charanraot2006 commented on GitHub (Nov 5, 2025):
Hi, I would like to work on this issue. Can you please assign it to me?
I will add a deterministic test array along with the existing random tests to ensure reproducibility and better debugging as mentioned in the description.
@Ujwal200707 commented on GitHub (Nov 6, 2025):
thank you for your response
@github-actions[bot] commented on GitHub (Dec 7, 2025):
This issue has been automatically marked as abandoned because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
@github-actions[bot] commented on GitHub (Dec 14, 2025):
Please ping one of the maintainers once you add more information and updates here. If this is not the case and you need some help, feel free to ask for help in our Gitter channel or our Discord server. Thank you for your contributions!