Skip to content
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

shell_sort.cpp: Add Shell Sort in C++ #273

Closed
wants to merge 3 commits into from

Conversation

joao-p-marques
Copy link

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!

Fixes #270

By submitting this pull request I confirm I've read and complied with the
below declarations.

  • I have read the Contribution guidelines and I am confident that my PR reflects them.
  • I have followed the commit guidelines for this project.
  • My code follows the standard code structure.
  • This pull request has a descriptive title. For example, {Tag}: Add {Algorithm/DS name} [{Language}], not Update README.md or Added new code.
  • This pull request will be closed if I fail to update it even once in a continuous time span of 7 days.
  • This pull request shall only be reviewed and merged once all the checks passes. No maintainer or supporter shall be obliged to review it before this condition is met.
  • I have mentioned the issue number correctly (with hyperlink) in this pull request description.

After you submit your pull request, DO NOT click the 'Update Branch' button.

int j = i;
while (j > 0 && a[j-1] > a[j]) {
// swap
int temp = a[j-1];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line ends in whitespace. Consider deleting these extra spaces. [whitespace/end_of_line] [4]

Origin: CPPLintBear, Section: all.cpplint.

}

cout << "After insertion sort: ";
for (int i = 0; i < a_size; i++){
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing space before { [whitespace/braces] [5]

Origin: CPPLintBear, Section: all.cpplint.


while (gap > 0) {
for (int i = 0; i < a_size - gap; i++) {
if (a[i] > a[i + gap]){
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing space before { [whitespace/braces] [5]

Origin: CPPLintBear, Section: all.cpplint.

for (int i = 0; i < a_size - gap; i++) {
if (a[i] > a[i + gap]){
// swap
int temp = a[i];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line ends in whitespace. Consider deleting these extra spaces. [whitespace/end_of_line] [4]

Origin: CPPLintBear, Section: all.cpplint.

// swap
int temp = a[i];
a[i] = a[i + gap];
a[i + gap] = temp;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line ends in whitespace. Consider deleting these extra spaces. [whitespace/end_of_line] [4]

Origin: CPPLintBear, Section: all.cpplint.

}

cout << "After shell sort: ";
for (int i = 0; i < a_size; i++){
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing space before { [whitespace/braces] [5]

Origin: CPPLintBear, Section: all.cpplint.

}
cout << std:: endl;

insertion_sort(a, a_size);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line ends in whitespace. Consider deleting these extra spaces. [whitespace/end_of_line] [4]

Origin: CPPLintBear, Section: all.cpplint.


shell_sort(a, a_size);

for (int i = 0; i < a_size; i++){
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing space before { [whitespace/braces] [5]

Origin: CPPLintBear, Section: all.cpplint.


for (int i = 0; i < a_size; i++){
cout << a[i] << " ";
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line ends in whitespace. Consider deleting these extra spaces. [whitespace/end_of_line] [4]

Origin: CPPLintBear, Section: all.cpplint.

for (int i = 0; i < a_size; i++){
cout << a[i] << " ";
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could not find a newline character at the end of the file. [whitespace/ending_newline] [5]

Origin: CPPLintBear, Section: all.cpplint.

Wrong push in this branch.
@sangamcse
Copy link
Member

Comment on eeb228c, file quicksort/Cpp/quick_sort.cpp, line 7.

Redundant blank line at the start of a code block should be deleted. [whitespace/blank_line] [2]

Origin: CPPLintBear, Section: all.cpplint.

@sangamcse
Copy link
Member

Comment on eeb228c, file quicksort/Cpp/quick_sort.cpp, line 24.

You don't need a ; after a } [readability/braces] [4]

Origin: CPPLintBear, Section: all.cpplint.

@sangamcse
Copy link
Member

Comment on eeb228c, file quicksort/Cpp/quick_sort.cpp, line 30.

Redundant blank line at the end of a code block should be deleted. [whitespace/blank_line] [3]

Origin: CPPLintBear, Section: all.cpplint.

@sangamcse
Copy link
Member

Comment on eeb228c, file quicksort/Cpp/quick_sort.cpp, line 33.

Missing space before { [whitespace/braces] [5]

Origin: CPPLintBear, Section: all.cpplint.

@sangamcse
Copy link
Member

Comment on eeb228c, file quicksort/Cpp/quick_sort.cpp, line 39.

Missing spaces around = [whitespace/operators] [4]

Origin: CPPLintBear, Section: all.cpplint.

@sangamcse
Copy link
Member

Comment on eeb228c, file quicksort/Cpp/quick_sort.cpp, line 39.

Missing spaces around < [whitespace/operators] [3]

Origin: CPPLintBear, Section: all.cpplint.

@sangamcse
Copy link
Member

Comment on eeb228c, file quicksort/Cpp/quick_sort.cpp, line 39.

Missing space before ( in for( [whitespace/parens] [5]

Origin: CPPLintBear, Section: all.cpplint.

@sangamcse
Copy link
Member

Comment on eeb228c, file quicksort/Cpp/quick_sort.cpp, line 39.

Missing space before { [whitespace/braces] [5]

Origin: CPPLintBear, Section: all.cpplint.

@sangamcse
Copy link
Member

Comment on eeb228c, file quicksort/Cpp/quick_sort.cpp, line 42.

Could not find a newline character at the end of the file. [whitespace/ending_newline] [5]

Origin: CPPLintBear, Section: all.cpplint.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Algo] Shell Sort [C++]
2 participants