-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
New issue
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
Merge sort added more efficient #1294
Merge sort added more efficient #1294
Conversation
Hey! @alexpantyukhin can you check? |
* @param [in,out] b pointer to second variable | ||
*/ | ||
void swap(int *a, int *b) | ||
// Function to merge two sorted subarrays into one sorted array |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why have you decreased the documentation please restore the old documentation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have removed the documentation of the "swap" function. because here I don't use the Swap function. so why I write documentation if it! I wrote more efficient code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Understood! Sorry for the confusion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Understood! Sorry for the confusion.
} | ||
|
||
/** Merge sort algorithm implementation | ||
* @param a array to sort | ||
* @param n number of elements in the array |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this style of documentation was prefered
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have added these portions.
sorting/merge_sort.c
Outdated
*/ | ||
void merge_sort(int *a, int n, int l, int r) | ||
// Merge sort function | ||
void mergeSort(int arr[], int left, int right) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think we use snake_case for all things naming
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
I have added documentation, I think no more need. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for taking time in reading my suggestions here are some more!
sorting/merge_sort.c
Outdated
|
||
/** Main function */ | ||
int main(void) | ||
int main() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
int main() | |
/** | |
* @brief main function | |
* @returns 0 on successful exit | |
*/ | |
int main() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added comment before main function.
sorting/merge_sort.c
Outdated
printf("Original array: "); | ||
for (int i = 0; i < n; i++) printf("%d ", arr[i]); | ||
|
||
merge_sort(arr, 0, n - 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please make a separate function for all the testing!
I am not that well read on c but if there is a static keyword please use that as well
static void tests(){
// tests here
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have added the test function.
*/ | ||
#include <assert.h> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these need to be documented as well
#include <header.h> /// <reason for header.h>
Description of Change
References
Checklist
Notes: