-
Notifications
You must be signed in to change notification settings - Fork 302
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.cpp: Add cpp merge sort. #492
Conversation
844e813
to
b0c29af
Compare
merge_sort/Cpp/merge_sort.cpp
Outdated
} | ||
|
||
void join (std::vector<int>& arr, int l, int m, int r) { | ||
// merge operation of merge sort. |
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.
Line contains following spacing inconsistencies:
- Spaces used instead of tabs.
Origin: SpaceConsistencyBear, Section: all.cpp
.
The issue can be fixed by applying the following patch:
--- a/tmp/tmpw4int4b9/merge_sort/Cpp/merge_sort.cpp
+++ b/tmp/tmpw4int4b9/merge_sort/Cpp/merge_sort.cpp
@@ -23,7 +23,7 @@
}
void join (std::vector<int>& arr, int l, int m, int r) {
- // merge operation of merge sort.
+ // merge operation of merge sort.
int i, j, k;
int s1 = m-l+1, s2 = r-m;
int L[s1], R[s2];
merge_sort/Cpp/merge_sort.cpp
Outdated
return 0; | ||
} | ||
|
||
void join (std::vector<int>& arr, int l, int m, int r) { |
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.
Extra space before ( in function call [whitespace/parens] [4]
Origin: CPPLintBear, Section: all.cpplint
.
merge_sort/Cpp/merge_sort.cpp
Outdated
arr[k] = L[i]; | ||
i++; | ||
} | ||
else { |
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.
An else should appear on the same line as the preceding } [whitespace/newline] [4]
Origin: CPPLintBear, Section: all.cpplint
.
merge_sort/Cpp/merge_sort.cpp
Outdated
arr[k] = L[i]; | ||
i++; | ||
} | ||
else { |
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.
If an else has a brace on one side, it should have it on both [readability/braces] [5]
Origin: CPPLintBear, Section: all.cpplint
.
merge_sort/Cpp/merge_sort.cpp
Outdated
} | ||
} | ||
|
||
void sort (std::vector<int>& arr, int l, int r) { |
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.
Extra space before ( in function call [whitespace/parens] [4]
Origin: CPPLintBear, Section: all.cpplint
.
merge_sort/Cpp/merge_sort.cpp
Outdated
} | ||
} | ||
|
||
void show (std::vector<int>& arr) { |
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.
Extra space before ( in function call [whitespace/parens] [4]
Origin: CPPLintBear, Section: all.cpplint
.
b0c29af
to
0d24866
Compare
@sangamcse Please Review. 🙂 |
0d24866
to
27ce9f0
Compare
README.md
Outdated
@@ -15,7 +15,7 @@ This repository contains examples of various algorithms written on different pro | |||
| Algorithm | C | CPP | Java | Python | | |||
|:----------------------------------------------------------------------------------------------- |:-------------------------------------:|:-------------------------------------:|:-------------------------------------:|:-------------------------------------:| | |||
| [Euclidean GCD](https://en.wikipedia.org/wiki/Euclidean_algorithm) | [:octocat:](euclidean_gcd/C) | | [:octocat:](euclidean_gcd/Java) | [:octocat:](euclidean_gcd/Python) | | |||
| [Merge Sort](https://en.wikipedia.org/wiki/Merge_sort) | [:octocat:](merge_sort/C) | | [:octocat:](merge_sort/Java) | [:octocat:](merge_sort/Python) | | |||
| [Merge Sort](https://en.wikipedia.org/wiki/Merge_sort) | [:octocat:](merge_sort/C) | [:octocat:](merge_sort/Cpp) | [:octocat:](merge_sort/Java) | [:octocat:](merge_sort/Python) | |
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.
you have used tabs.
merge_sort/Cpp/merge_sort.cpp
Outdated
int main() { | ||
int n = 10, a, i, arr[] = {2, 4, 3, 6, 5, 1, 9, 0, 8, 7}; | ||
// scanf("%d", &n); //For custom input | ||
// printf("Enter %ld number (space separated): ", n); //For custom inup |
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.
Remove scanf and printf from cpp code.
Cpp implementation of merge sort for NITSkmOS/Algorithms closes NITSkmOS#258
27ce9f0
to
61daeaf
Compare
@sangamcse Please review 🙂 |
ack 61daeaf |
@sangamcse ff |
Hey! I'm GitMate.io! This pull request is being fastforwarded automatically. Please DO NOT push while fastforward is in progress or your changes would be lost permanently |
Automated fastforward with GitMate.io was successful! 🎉 |
Cpp implementation of merge sort for NITSkmOS/Algorithms.
closes #258
For short term contributors: we understand that getting your commits well
defined like we require is a hard task and takes some learning. If you
look to help without wanting to contribute long term there's no need
for you to learn this. Just drop us a message and we'll take care of brushing
up your stuff for merge!
By submitting this pull request I confirm I've read and complied with the
below declarations.
{Tag}: Add {Algorithm/DS name} [{Language}]
, notUpdate README.md
orAdded new code
.After you submit your pull request, DO NOT click the 'Update Branch' button.