fixed documentation

This commit is contained in:
Ayaan Khan 2020-06-20 21:41:25 +05:30
parent 0a09c1e382
commit 99ca279ff6

View File

@ -1,11 +1,11 @@
/** /**
* \addtogroup sorting Sorting Algorithms * \addtogroup sorting Sorting Algorithms
* @file{ * @{
* \file * \file
* \breif [Merege Sort Algorithm * \brief [Merege Sort Algorithm
* (MEREGE SORT)](https://en.wikipedia.org/wiki/Merge_sort) implementation * (MEREGE SORT)](https://en.wikipedia.org/wiki/Merge_sort) implementation
* *
* \author [Ayaan Khan] (http://github.com/ayaankhan98) * \author [Ayaan Khan](http://github.com/ayaankhan98)
* *
* \details * \details
* Merge Sort is an efficient, general purpose, comparison * Merge Sort is an efficient, general purpose, comparison
@ -22,16 +22,15 @@
* arr[l..m] and arr[m+1..r] are sorted and merges the two * arr[l..m] and arr[m+1..r] are sorted and merges the two
* sorted sub-arrays into one. * sorted sub-arrays into one.
* *
* @param arr[] is the array with two halves one is arr[l...m] and * @param arr - array with two halves arr[l...m] and arr[m+1...l]
* other is arr[m+1...l] * @param l - left index or start index of first half array
* @param l is the left index of first half array * @param m - right index or end index of first half array
* @param m is the end index of right index of first half array
* *
* (The second array starts form m+1 and goes till l) * (The second array starts form m+1 and goes till l)
* *
* @param l is the end index of right index of second half array * @param l - end index or right index of second half array
*/ */
void merge(int arr[], int l, int m, int r) { void merge(int *arr, int l, int m, int r) {
int i, j, k; int i, j, k;
int n1 = m - l + 1; int n1 = m - l + 1;
int n2 = r - m; int n2 = r - m;
@ -76,12 +75,12 @@ void merge(int arr[], int l, int m, int r) {
* input array into two halves and calls itself for the two halves * input array into two halves and calls itself for the two halves
* and then calls merge() to merge the two halves * and then calls merge() to merge the two halves
* *
* @param arr[] the array which is to be sorted * @param arr - array to be sorted
* @param l define the left index of array * @param l - left index or start index of array
* @param r defines the right index of array * @param r - right index or end index of array
* *
*/ */
void mergeSort(int arr[], int l, int r) { void mergeSort(int *arr, int l, int r) {
if (l < r) { if (l < r) {
int m = l + (r - l) / 2; int m = l + (r - l) / 2;
mergeSort(arr, l, m); mergeSort(arr, l, m);
@ -91,10 +90,10 @@ void mergeSort(int arr[], int l, int r) {
} }
/** /**
* A simple utility function used to print the array after * Utility function used to print the array after
* sorting * sorting
*/ */
void show(int arr[], int size) { void show(int *arr, int size) {
for (int i = 0; i < size; i++) std::cout << arr[i] << " "; for (int i = 0; i < size; i++) std::cout << arr[i] << " ";
std::cout << "\n"; std::cout << "\n";
} }