Skip to content

Commit 2daf0a6

Browse files
authored
Fix editorconfig issues (iiitv#331)
* use eclint * fix source files * define eclint version This will help us avoid issues in the future * fix indentation issues in CountingSort.java
1 parent fc1413b commit 2daf0a6

39 files changed

Lines changed: 631 additions & 627 deletions

‎.editorconfig‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
root = true
22

33
[*]
4+
charset = utf-8
45
end_of_line = lf
56
insert_final_newline = true
67

78
[*.{go,c,cpp}]
8-
charset = utf-8
99
indent_style = tab
1010
tab_width = 4
1111
trim_trailing_whitespace = true
@@ -15,12 +15,16 @@ indent_style = tab
1515
tab_width = 2
1616
trim_trailing_whitespace = true
1717

18-
[.{py,java}]
19-
charset = utf-8
18+
[*.{py,java}]
2019
indent_style = space
2120
indent_size = 4
2221
trim_trailing_whitespace = true
2322

23+
[*.{c,cpp,java,js}]
24+
block_comment_start = /*
25+
block_comment = *
26+
block_comment_end = */
27+
2428
[*.yml]
2529
indent_style = space
2630
indent_size = 2

‎.travis.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ install:
1818
script:
1919
- ./.bin/test_running.sh
2020
- coala --ci
21-
- if editorconfig-tools check **/* | grep " failed "; then false; else true; fi
21+
- eclint check "**/*.{java,c,cpp,js}"

‎bin_sort/BinSort.java‎

Lines changed: 63 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,75 @@
11
import java.util.Random;
22

33
class Node {
4-
public double data;
5-
public Node next;
4+
public double data;
5+
public Node next;
66

7-
public Node(double data) {
8-
this.data = data;
9-
next = null;
10-
}
7+
public Node(double data) {
8+
this.data = data;
9+
next = null;
10+
}
1111
}
1212

1313
// Time Complexity O(n)-> avg case and O(n^2)-> Worst Case
1414
// constraints:- 0<=A[i]<1
1515
public class BinSort {
16-
public static void binSort(Node[] b, double[] a) {
17-
for (int i = 0; i < a.length; i++) {
18-
int ins = (int) (a[i] * b.length);
19-
if (b[ins] == null) {
20-
b[ins] = new Node(a[i]);
21-
} else {
22-
boolean check = true;
23-
Node temp = b[ins];
24-
while (temp.next != null) {
25-
if (a[i] > temp.next.data) {
26-
temp = temp.next;
27-
} else {
28-
if (a[i] < temp.data)
29-
break;
30-
Node newNode = new Node(a[i]);
31-
newNode.next = temp.next;
32-
temp.next = newNode;
33-
check = false;
34-
break;
35-
}
36-
}
37-
if (check) {
38-
if (a[i] >= temp.data) {
39-
Node newNode = new Node(a[i]);
40-
temp.next = newNode;
41-
} else {
42-
double loc = temp.data;
43-
temp.data = a[i];
44-
Node newNode = new Node(loc);
45-
newNode.next = temp.next;
46-
temp.next = newNode;
47-
}
48-
}
49-
}
50-
}
51-
int j = 0;
52-
for (int i = 0; i < b.length; i++) {
53-
while (b[i] != null) {
54-
a[j++] = b[i].data;
55-
b[i] = b[i].next;
56-
}
57-
}
58-
}
16+
public static void binSort(Node[] b, double[] a) {
17+
for (int i = 0; i < a.length; i++) {
18+
int ins = (int) (a[i] * b.length);
19+
if (b[ins] == null) {
20+
b[ins] = new Node(a[i]);
21+
} else {
22+
boolean check = true;
23+
Node temp = b[ins];
24+
while (temp.next != null) {
25+
if (a[i] > temp.next.data) {
26+
temp = temp.next;
27+
} else {
28+
if (a[i] < temp.data)
29+
break;
30+
Node newNode = new Node(a[i]);
31+
newNode.next = temp.next;
32+
temp.next = newNode;
33+
check = false;
34+
break;
35+
}
36+
}
37+
if (check) {
38+
if (a[i] >= temp.data) {
39+
Node newNode = new Node(a[i]);
40+
temp.next = newNode;
41+
} else {
42+
double loc = temp.data;
43+
temp.data = a[i];
44+
Node newNode = new Node(loc);
45+
newNode.next = temp.next;
46+
temp.next = newNode;
47+
}
48+
}
49+
}
50+
}
51+
int j = 0;
52+
for (int i = 0; i < b.length; i++) {
53+
while (b[i] != null) {
54+
a[j++] = b[i].data;
55+
b[i] = b[i].next;
56+
}
57+
}
58+
}
5959

60-
public static void main(String[] args) {
61-
Node[] b = new Node[10];
62-
Random ran = new Random();
63-
int n = 100;
64-
double[] a = new double[n];
65-
for (int i = 0; i < n; i++) {
66-
a[i] = ran.nextDouble();
67-
}
68-
binSort(b, a);
69-
for (int i = 0; i < n; i++) {
70-
System.out.print(a[i] + " ");
71-
}
72-
System.out.println(" ");
73-
}
60+
public static void main(String[] args) {
61+
Node[] b = new Node[10];
62+
Random ran = new Random();
63+
int n = 100;
64+
double[] a = new double[n];
65+
for (int i = 0; i < n; i++) {
66+
a[i] = ran.nextDouble();
67+
}
68+
binSort(b, a);
69+
for (int i = 0; i < n; i++) {
70+
System.out.print(a[i] + " ");
71+
}
72+
System.out.println(" ");
73+
}
7474
}
7575

‎binary_search/BinarySearch.java‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ static int binarySearch(int[] arr, int searchElement) {
55
int right = arr.length - 1;
66
while (left <= right) {
77
int mid = (left + right) / 2;
8-
if (arr[mid] == searchElement) { // Element found
8+
if (arr[mid] == searchElement) { // Element found
99
return mid;
1010
}
11-
if (arr[mid] < searchElement) { // Look in right half
11+
if (arr[mid] < searchElement) { // Look in right half
1212
left = mid + 1;
13-
} else { // Look in left half
13+
} else { // Look in left half
1414
right = mid - 1;
1515
}
1616
}
@@ -23,7 +23,7 @@ public static void main(String[] args) {
2323
int[] searchArr = new int[] {1, 35, 112, 324, 67};
2424
int pos;
2525
for (int i = 0; i < searchArr.length; i++) {
26-
pos = binarySearch(arr, searchArr[i]); //search key and get poistion
26+
pos = binarySearch(arr, searchArr[i]); //search key and get poistion
2727
if (pos >= 0) {
2828
System.out.println(searchArr[i] + "-> found at index : " + pos);
2929
} else {

‎binary_search/binary_search.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ function binarySearchIterative (arr, item) {
44
:param arr: List of elements to search from
55
:param item: Element to search for
66
:return: returns index if element found else -1
7-
*/
7+
*/
88
let begin = 0;
99
let end = arr.length - 1;
1010
while (begin <= end) {
@@ -28,7 +28,7 @@ function binarySearchRecursive (arr, item, begin, end) {
2828
:param begin: Left limit of array
2929
:param end: Right limit of array
3030
:return: returns index if element found else -1
31-
*/
31+
*/
3232
if (begin <= end) {
3333
let mid = Math.floor((begin + end) / 2);
3434
if (arr[mid] === item) {

0 commit comments

Comments
 (0)