Skip to content

Conversation

gdhameeja
Copy link

This adds Counting Sort implemented in java.
It returns the sorted array.
Here is the wiki link : https://en.wikipedia.org/wiki/Counting_sort

@sangamcse
Copy link
Member

Comment on d133706, file counting_sort/Java/count_sort.java, line 28.

Line contains following spacing inconsistencies:

  • Trailing whitespaces.

Origin: SpaceConsistencyBear, Section: all.pyjava.

The issue can be fixed by applying the following patch:

--- a/tmp/tmp3fxanglr/counting_sort/Java/count_sort.java
+++ b/tmp/tmp3fxanglr/counting_sort/Java/count_sort.java
@@ -25,7 +25,7 @@
          */
         int maximum_number = getMax(arr);              // get the max number in the array in order to declare count array.
         int[] count_arr = new int[maximum_number + 1]; // maximum_number + 1 as we need to correctly
-                                                      //map each index with the number in the array 
+                                                      //map each index with the number in the array
 
         for (int i = 0; i < count_arr.length; i++) {
             count_arr[i] = 0;

@sangamcse

This comment has been minimized.

@gdhameeja
Copy link
Author

I think the patch suggests I have CountSort.java as the filename. I changed that to count_sort.java to adhere to the repo coding guidelines. Can you provide a new patch please?
@sangamcse

@gdhameeja
Copy link
Author

I converted all tabs to spaces. Please let me know in case of any other issues.

@sangamcse
Copy link
Member

Comment on 8f1a886, file counting_sort/Java/CountSort.java, line 28.

Line contains following spacing inconsistencies:

  • Trailing whitespaces.

Origin: SpaceConsistencyBear, Section: all.pyjava.

The issue can be fixed by applying the following patch:

--- a/tmp/tmpc_mpjr4g/counting_sort/Java/CountSort.java
+++ b/tmp/tmpc_mpjr4g/counting_sort/Java/CountSort.java
@@ -25,7 +25,7 @@
          */
         int maximum_number = getMax(arr);              // get the max number in the array in order to declare count array.
         int[] count_arr = new int[maximum_number + 1]; // maximum_number + 1 as we need to correctly
-                                                      //map each index with the number in the array 
+                                                      //map each index with the number in the array
 
         for (int i = 0; i < count_arr.length; i++) {
             count_arr[i] = 0;

@gdhameeja
Copy link
Author

@sangamcse This is my first pull request. How do I apply this patch?
Steps I took:
Copied the current url and used wget url.patch
Then tried git apply 377.patch but it gave errors.
Kindly guide me.

import java.util.Collections;

class CountSort {
/**
Copy link
Member

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:

  • Trailing whitespaces.

Origin: SpaceConsistencyBear, Section: all.pyjava.

The issue can be fixed by applying the following patch:

--- a/tmp/tmpn7_d42aj/counting_sort/Java/count_sort.java
+++ b/tmp/tmpn7_d42aj/counting_sort/Java/count_sort.java
@@ -25,7 +25,7 @@
          */
         int maximum_number = getMax(arr);              // get the max number in the array in order to declare count array.
         int[] count_arr = new int[maximum_number + 1]; // maximum_number + 1 as we need to correctly
-                                                       //map each index with the number in the array 
+                                                       //map each index with the number in the array
 
         for (int i = 0; i < count_arr.length; i++) {
             count_arr[i] = 0;

Copy link
Author

Choose a reason for hiding this comment

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

@sangamcse Hey Sangam, I am unable to apply patches.
These are the errors I get ->
error: counting_sort/Java/CountSort.java: No such file or directory
error: patch failed: counting_sort/Java/count_sort.java:37
error: counting_sort/Java/count_sort.java: patch does not apply
error: counting_sort/Java/CountSort.java: No such file or directory
Can you please help me with this?

import java.util.Collections;

class CountSort {
/**
Copy link
Member

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:

  • Trailing whitespaces.

Origin: SpaceConsistencyBear, Section: all.pyjava.

The issue can be fixed by applying the following patch:

--- a/tmp/tmpwep5ebii/counting_sort/Java/count_sort.java
+++ b/tmp/tmpwep5ebii/counting_sort/Java/count_sort.java
@@ -25,7 +25,7 @@
          */
         int maximum_number = getMax(arr);              // get the max number in the array in order to declare count array.
         int[] count_arr = new int[maximum_number + 1]; // maximum_number + 1 as we need to correctly
-                                                        //map each index with the number in the array 
+                                                        //map each index with the number in the array
 
         for (int i = 0; i < count_arr.length; i++) {
             count_arr[i] = 0;

Copy link
Member

@sangamcse sangamcse left a comment

Choose a reason for hiding this comment

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

Squash your commits into one

@sangamcse
Copy link
Member

@gdhameeja gdhameeja closed this Oct 14, 2018
@gdhameeja gdhameeja deleted the java-counting-sort branch October 14, 2018 09:54
@gdhameeja gdhameeja restored the java-counting-sort branch October 14, 2018 09:57
@gdhameeja gdhameeja deleted the java-counting-sort branch October 14, 2018 11:39
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.

2 participants