From 02243638037e770a25a259ba8710ca060770ffff Mon Sep 17 00:00:00 2001 From: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> Date: Fri, 19 Jun 2020 16:10:22 +0000 Subject: [PATCH 1/3] formatting source-code for f541be97244b89a9279a46ca1c33c75865127c7e --- sorting/quick_sort.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sorting/quick_sort.cpp b/sorting/quick_sort.cpp index 76c2a7184..ff66b4cf2 100644 --- a/sorting/quick_sort.cpp +++ b/sorting/quick_sort.cpp @@ -96,6 +96,6 @@ int main() { quickSort(arr, 0, size); std::cout << "Sorted array\n"; show(arr, size); - delete [] arr; + delete[] arr; return 0; } From 69f7c9c6e1657caaa351ef9e259d1b5bfa25befd Mon Sep 17 00:00:00 2001 From: Krishna Vedala <7001608+kvedala@users.noreply.github.com> Date: Sat, 20 Jun 2020 07:27:41 -0400 Subject: [PATCH 2/3] [fix] Enable CI for pull_requests (#864) * rename awesome workflow * added new PR workflow - only cpplint and compilation * simple doc add * rename PR workflow * removed cpplint dependency * try v1 checkout * remove pr specific CI * remove dependency to perform git pull * remove blank line * remove checkout@master and use v1 * remove hyphen * remove misplaced with statement * remove redundant git pull * try git pull from origin for compile check * remove git pull altogehter * use setup-python-v2 --- ...some_forkflow.yml => awesome_workflow.yml} | 62 +++++-------------- 1 file changed, 15 insertions(+), 47 deletions(-) rename .github/workflows/{awesome_forkflow.yml => awesome_workflow.yml} (82%) diff --git a/.github/workflows/awesome_forkflow.yml b/.github/workflows/awesome_workflow.yml similarity index 82% rename from .github/workflows/awesome_forkflow.yml rename to .github/workflows/awesome_workflow.yml index 93b630d05..f8feb1d3e 100644 --- a/.github/workflows/awesome_forkflow.yml +++ b/.github/workflows/awesome_workflow.yml @@ -1,23 +1,22 @@ name: Awesome CI Workflow -on: [push] +on: [push, pull_request] # push: # branches: [ master ] # pull_request: # branches: [ master ] jobs: - code_format: + MainSequence: name: Code Formatter runs-on: ubuntu-latest steps: + - uses: actions/checkout@v1 # v2 is broken for git diff + - uses: actions/setup-python@v2 - name: requirements run: | sudo apt -qq -y update - sudo apt -qq install clang-format - - uses: actions/checkout@master - with: - submodules: true + sudo apt -qq install clang-format - name: Setup Git Specs run: | git config --global user.name github-actions @@ -56,18 +55,7 @@ jobs: line2: "IndentWidth: 4, TabWidth: 4, " line3: "AllowShortIfStatementsOnASingleLine: false, IndentCaseLabels: false," line4: "ColumnLimit: 80, AccessModifierOffset: -3 }" - - name: Git Push - run: git push --force origin HEAD:$GITHUB_REF || true - - update_directory_md: - name: Update Directory.md - needs: code_format - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v1 - - name: pull latest commit - run: git pull + - name: Update DIRECTORY.md shell: python run: | @@ -121,32 +109,14 @@ jobs: git add DIRECTORY.md git commit -am "updating DIRECTORY.md" || true git push --force origin HEAD:$GITHUB_REF || true - - # cpplint: - # name: CPPLINT - # needs: code_format - # runs-on: ubuntu-latest - # steps: - # - uses: actions/checkout@master - # - uses: actions/setup-python@master - # - run: pip install cpplint - # - run: git pull - # - run: cpplint --filter=-legal --recursive . - - cpplint_modified_files: - runs-on: ubuntu-latest - needs: code_format - name: CPPLINT - steps: - - uses: actions/checkout@master # v2 is broken for git diff - - uses: actions/setup-python@master - - run: python -m pip install cpplint - - run: git remote -v - - run: git branch - - run: git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY - - run: git pull - - run: git diff --diff-filter=dr --name-only origin/master > git_diff.txt - - run: echo "Files changed-- `cat git_diff.txt`" + - name: Install CPPLINT + run: | + python -m pip install cpplint + git remote -v + git branch + git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY + git diff --diff-filter=dr --name-only origin/master > git_diff.txt + echo "Files changed-- `cat git_diff.txt`" - name: cpplint_modified_files shell: python run: | @@ -197,8 +167,7 @@ jobs: build: name: Compile checks runs-on: ${{ matrix.os }} - # needs: [cpplint, update_directory_md, cpplint_modified_files] - needs: [update_directory_md] + needs: [MainSequence] strategy: matrix: os: [ubuntu-latest, windows-latest, macOS-latest] @@ -206,6 +175,5 @@ jobs: - uses: actions/checkout@master with: submodules: true - - run: git pull - run: cmake -B ./build -S . - run: cmake --build build From edc17ec9e85ad5d2d371990009aa796de21eff06 Mon Sep 17 00:00:00 2001 From: Ayaan Khan Date: Sat, 20 Jun 2020 23:04:56 +0530 Subject: [PATCH 3/3] Fixed Bug in sorting/merge_sort.cpp (#872) * formatting source-code for 72c365dcd34d9776fac3e2b58b41891b3619b02e * Fixed Bug [munmap_chunck() core dumped] * formatting source-code for b06bbf4dc6c46a3284d7852bb570438384eef4ef * fixed line spacing * fixed line spacing * fixed documentation * closed the paranthesis of line 3 * formatting source-code for 8233eda8894f46785f288e72c639d201852f6096 Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> --- sorting/merge_sort.cpp | 76 +++++++++++++++++++++++++++++++----------- 1 file changed, 56 insertions(+), 20 deletions(-) diff --git a/sorting/merge_sort.cpp b/sorting/merge_sort.cpp index 82ab869cd..fc6d66af5 100644 --- a/sorting/merge_sort.cpp +++ b/sorting/merge_sort.cpp @@ -1,6 +1,36 @@ +/** + * \addtogroup sorting Sorting Algorithms + * @{ + * \file + * \brief [Merege Sort Algorithm + * (MEREGE SORT)](https://en.wikipedia.org/wiki/Merge_sort) implementation + * + * \author [Ayaan Khan](http://github.com/ayaankhan98) + * + * \details + * Merge Sort is an efficient, general purpose, comparison + * based sorting algorithm. + * Merge Sort is a divide and conquer algorithm + * + */ #include -void merge(int arr[], int l, int m, int r) { +/** + * + * The merge() function is used for merging two halves. + * The merge(arr, l, m, r) is key process that assumes that + * arr[l..m] and arr[m+1..r] are sorted and merges the two + * sorted sub-arrays into one. + * + * @param arr - array with two halves arr[l...m] and arr[m+1...l] + * @param l - left index or start index of first half array + * @param m - right index or end index of first half array + * + * (The second array starts form m+1 and goes till l) + * + * @param l - end index or right index of second half array + */ +void merge(int *arr, int l, int m, int r) { int i, j, k; int n1 = m - l + 1; int n2 = r - m; @@ -40,42 +70,48 @@ void merge(int arr[], int l, int m, int r) { delete[] R; } -void mergeSort(int arr[], int l, int r) { +/** + * Merge sort is a divide and conquer algorithm, it divides the + * input array into two halves and calls itself for the two halves + * and then calls merge() to merge the two halves + * + * @param arr - array to be sorted + * @param l - left index or start index of array + * @param r - right index or end index of array + * + */ +void mergeSort(int *arr, int l, int r) { if (l < r) { int m = l + (r - l) / 2; - mergeSort(arr, l, m); mergeSort(arr, m + 1, r); - merge(arr, l, m, r); } } -void show(int A[], int size) { - int i; - for (i = 0; i < size; i++) std::cout << A[i] << "\n"; +/** + * Utility function used to print the array after + * sorting + */ +void show(int *arr, int size) { + for (int i = 0; i < size; i++) std::cout << arr[i] << " "; + std::cout << "\n"; } +/** Main function */ int main() { int size; - std::cout << "\nEnter the number of elements : "; - + std::cout << "Enter the number of elements : "; std::cin >> size; - int *arr = new int[size]; - - std::cout << "\nEnter the unsorted elements : "; - + std::cout << "Enter the unsorted elements : "; for (int i = 0; i < size; ++i) { - std::cout << "\n"; std::cin >> arr[i]; } - - mergeSort(arr, 0, size); - - std::cout << "Sorted array\n"; - show(arr, size); - + mergeSort(arr, 0, size - 1); + std::cout << "Sorted array : "; + show(arr, size - 1); delete[] arr; return 0; } +/** @} */