We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I was trying to understand why my implementation of quicksort was not working, and figured I'd look at this repo for some insights.
The array input that I am testing is:
int nbr[8] = {3, 1, 2, 0, 8, 9, 11, -1};
If I print the elements after sorting, I see:
nbr failed -1 1 2 0 3 8 9 11 nbr_small passed nbr_null passed
0 is at index 4, instead of index 2.
Following is main with my modifications:
main
int main(void){ int nbr[8] = {3, 1, 2, 0, 8, 9, 11, -1}; int nbr_small[2] = {100, 2}; int *nbr_null = NULL; quicksort(nbr, 8); quicksort(nbr_small, 2); quicksort(nbr_null, 10); if(is_sorted(nbr, 8)) printf("nbr passed\n"); else printf("nbr failed\n"); for (int i = 0; i < 8; i++) { printf("%d ", nbr[i]); } printf("\n"); if(is_sorted(nbr_small, 2)) printf("nbr_small passed\n"); else printf("nbr_small failed\n"); if(nbr_null == NULL) printf("nbr_null passed\n"); else printf("nbr_null failed\n"); return EXIT_SUCCESS; }
Quick diff:
int main(void){ | int main(){ int nbr[8] = {3, 1, 2, 0, 8, 9, 11, -1}; | int i; > int nbr[5] = {10, 1, 0, 5, 2}; quicksort(nbr, 8); | quicksort(nbr, 5); if(is_sorted(nbr, 8)) | if(is_sorted(nbr, 5)) for (int i = 0; i < 8; i++) { < printf("%d ", nbr[i]); < } < printf("\n"); <
The text was updated successfully, but these errors were encountered:
No branches or pull requests
I was trying to understand why my implementation of quicksort was not working, and figured I'd look at this repo for some insights.
The array input that I am testing is:
If I print the elements after sorting, I see:
0 is at index 4, instead of index 2.
Following is
main
with my modifications:Quick diff:
The text was updated successfully, but these errors were encountered: