Skip to content

Commit 0b23a48

Browse files
committed
Package name changed lowerclass
1 parent 6e92a85 commit 0b23a48

File tree

117 files changed

+285
-404
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

117 files changed

+285
-404
lines changed

src/main/java/codechef/MinimumStepsToOneDynamicProgramming.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
*/
5050
public class MinimumStepsToOneDynamicProgramming {
5151

52-
public static void main(String args[]) {
52+
public static void main(String[] args) {
5353
int positiveInt = 7;
5454
int expected = 3;
5555

src/main/java/codility/PassingCars.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
public class PassingCars {
2626

27-
public static void main(String args[]) {
27+
public static void main(String[] args) {
2828
// pairs7();
2929
pairs5();
3030
}

src/main/java/datastructures/BasicComparatorExample.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -266,9 +266,9 @@ public String toString(){
266266
* iterable.
267267
*/
268268
class Employee implements Comparable<Employee> {
269-
private int id;
270-
private String name;
271-
private String address;
269+
private final int id;
270+
private final String name;
271+
private final String address;
272272

273273
public Employee(int id, String name, String address) {
274274
this.id = id;
@@ -297,8 +297,8 @@ public int compareTo(Employee o) {
297297
*/
298298
public static Comparator<Employee> COMPARE_BY_NAME = new Comparator<Employee>() {
299299
public int compare(Employee o1, Employee o2) {
300-
Employee e1 = (Employee)o1;
301-
Employee e2 = (Employee)o2;
300+
Employee e1 = o1;
301+
Employee e2 = o2;
302302

303303
int nameCmp = e1.name.compareTo(e2.name);
304304
if ( nameCmp != 0 )

src/main/java/datastructures/BinarySearchMain.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*/
88
public class BinarySearchMain {
99

10-
public static void main(String args[])
10+
public static void main(String[] args)
1111
{
1212
mainIterative();
1313

@@ -16,7 +16,7 @@ public static void main(String args[])
1616
static void mainRecursive()
1717
{
1818
BinarySearchRecursive ob = new BinarySearchRecursive();
19-
int arr[] = { 2, 3, 4, 10, 40 };
19+
int[] arr = { 2, 3, 4, 10, 40 };
2020
int n = arr.length;
2121
int x = 10;
2222
int result = ob.binarySearch(arr, 0, n - 1, x);
@@ -29,7 +29,7 @@ static void mainRecursive()
2929
static void mainIterative()
3030
{
3131
BinarySearchIterative ob = new BinarySearchIterative();
32-
int arr[] = { 2, 3, 4, 10, 40 };
32+
int[] arr = { 2, 3, 4, 10, 40 };
3333
int n = arr.length;
3434
int x = 10;
3535
int result = ob.binarySearch(arr, x);
@@ -53,7 +53,7 @@ static void mainIterative()
5353
class BinarySearchRecursive {
5454
// Returns index of x if it is present in arr[l..
5555
// r], else return -1
56-
int binarySearch(int arr[], int l, int r, int x)
56+
int binarySearch(int[] arr, int l, int r, int x)
5757
{
5858
if (r >= l) {
5959
int mid = l + (r - l) / 2;
@@ -89,7 +89,7 @@ int binarySearch(int arr[], int l, int r, int x)
8989
class BinarySearchIterative {
9090
// Returns index of x if it is present in arr[],
9191
// else return -1
92-
int binarySearch(int arr[], int x)
92+
int binarySearch(int[] arr, int x)
9393
{
9494
int l = 0, r = arr.length - 1;
9595
while (l <= r) {

src/main/java/datastructures/BinaryTree.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ public static int max(BinaryTreeNode root) {
101101
return max(root.right);
102102
}
103103

104-
public static void main(String args[]){
104+
public static void main(String[] args){
105105
// Scanner sc=new Scanner(System.in);
106106
// int T=sc.nextInt();
107107
int[] nodes = {3, 5, 2, 1, 4, 6, 7};

src/main/java/datastructures/BinaryTreeHackerRank.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,12 @@ public boolean contains(T value) {
6969
return true;
7070
}
7171
else if(value.compareTo(data) < 0) {
72-
return (left == null)
73-
? false // Not found; there are no more BinaryTreeHackerRanks in left subtree to check
74-
: left.contains(value); // Continue searching left subtree
72+
// Not found; there are no more BinaryTreeHackerRanks in left subtree to check
73+
return left != null && left.contains(value); // Continue searching left subtree
7574
}
7675
else { // data.compareTo(value) > 0
77-
return (right == null)
78-
? false // Not found; there are no more BinaryTreeHackerRanks in right subrtree to check
79-
: right.contains(value); // Continue searching right subtree
76+
// Not found; there are no more BinaryTreeHackerRanks in right subrtree to check
77+
return right != null && right.contains(value); // Continue searching right subtree
8078
}
8179
}
8280

src/main/java/datastructures/BubbleSort.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public static void main(String[] args) {
8686
// bubbleSortV2(a);
8787
// System.out.println(Arrays.toString(a));
8888

89-
List<Integer> arrayList = new ArrayList<Integer>();;
89+
List<Integer> arrayList = new ArrayList<Integer>();
9090
arrayList.addAll(list);
9191
arrayList.get(0);
9292
arrayList.add(0, 12);

src/main/java/datastructures/DataStructuresInJava.java

Lines changed: 25 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ public static void basicStack(){
117117
stacka.push(2);
118118
System.out.println(stacka.pop().toString()); // 2
119119
stacka.push(3);
120-
System.out.println(stacka.toString()); // [1, 3]
120+
System.out.println(stacka); // [1, 3]
121121
}
122122

123123
public static void basicQueue() {
@@ -129,17 +129,17 @@ public static void basicQueue() {
129129
stack.push(1);
130130
stack.push(2);
131131
stack.push(3);
132-
System.out.println(stack.toString()); // [1, 2, 3]
132+
System.out.println(stack); // [1, 2, 3]
133133

134134
while (!stack.isEmpty()) {
135135
queue.enqueue(stack.pop());
136136
}
137-
System.out.println(queue.toString());
137+
System.out.println(queue);
138138

139139
while (!queue.isEmpty()) {
140140
stack.push(queue.dequeue());
141141
}
142-
System.out.println(stack.toString()); // [3, 2, 1]
142+
System.out.println(stack); // [3, 2, 1]
143143
}
144144

145145
public static void basicsHashMaps() {
@@ -236,7 +236,7 @@ The time complexity of Priority Queue for insertion(enqueue) and deletion (deque
236236
// System.out.println(iter.next() + " ");
237237
// }
238238

239-
System.out.println(cities_queue.toString());
239+
System.out.println(cities_queue);
240240
}
241241

242242
public static void maxPriorityQueue() {
@@ -367,7 +367,7 @@ the deque interface is memory efficient
367367
*/
368368
class ArrayQueue {
369369
private static int front, rear, capacity;
370-
private static int queue[];
370+
private static int[] queue;
371371

372372
ArrayQueue(int size) {
373373
front = rear = 0;
@@ -379,7 +379,7 @@ class ArrayQueue {
379379
static void queueEnqueue(int item) {
380380
// check if the queue is full
381381
if (capacity == rear) {
382-
System.out.printf("\nQueue is full\n");
382+
System.out.print("\nQueue is full\n");
383383
return;
384384
}
385385

@@ -388,14 +388,13 @@ static void queueEnqueue(int item) {
388388
queue[rear] = item;
389389
rear++;
390390
}
391-
return;
392391
}
393392

394393
//remove an element from the queue
395394
static void queueDequeue() {
396395
// check if queue is empty
397396
if (front == rear) {
398-
System.out.printf("\nQueue is empty\n");
397+
System.out.print("\nQueue is empty\n");
399398
return;
400399
}
401400

@@ -413,71 +412,68 @@ static void queueDequeue() {
413412
// decrement rear
414413
rear--;
415414
}
416-
return;
417415
}
418416

419417
// print queue elements
420418
static void queueDisplay()
421419
{
422420
int i;
423421
if (front == rear) {
424-
System.out.printf("Queue is Empty\n");
422+
System.out.print("Queue is Empty\n");
425423
return;
426424
}
427425

428426
// traverse front to rear and print elements
429427
for (i = front; i < rear; i++) {
430428
System.out.printf(" %d = ", queue[i]);
431429
}
432-
return;
433430
}
434431

435432
// print front of queue
436433
static void queueFront()
437434
{
438435
if (front == rear) {
439-
System.out.printf("Queue is Empty\n");
436+
System.out.print("Queue is Empty\n");
440437
return;
441438
}
442439
System.out.printf("\nFront Element of the queue: %d", queue[front]);
443-
return;
444440
}
445441
public static void main(String[] args) {
446442
// Create a queue of capacity 4
447443
ArrayQueue q = new ArrayQueue(4);
448444

449445
System.out.println("Initial Queue:");
450446
// print Queue elements
451-
q.queueDisplay();
447+
queueDisplay();
452448

453449
// inserting elements in the queue
454-
q.queueEnqueue(10);
455-
q.queueEnqueue(30);
456-
q.queueEnqueue(50);
457-
q.queueEnqueue(70);
450+
queueEnqueue(10);
451+
queueEnqueue(30);
452+
queueEnqueue(50);
453+
queueEnqueue(70);
458454

459455
// print Queue elements
460456
System.out.println("Queue after Enqueue Operation:");
461-
q.queueDisplay();
457+
queueDisplay();
462458

463459
// print front of the queue
464-
q.queueFront();
460+
queueFront();
465461

466462
// insert element in the queue
467-
q.queueEnqueue(90);
463+
queueEnqueue(90);
468464

469465
// print Queue elements
470-
q.queueDisplay();
466+
queueDisplay();
471467

472-
q.queueDequeue();
473-
q.queueDequeue();
474-
System.out.printf("\nQueue after two dequeue operations:");
468+
queueDequeue();
469+
queueDequeue();
470+
System.out.print("\nQueue after two dequeue operations:");
475471

476472
// print Queue elements
477-
q.queueDisplay();
473+
queueDisplay();
478474

479475
// print front of the queue
480-
q.queueFront();
476+
queueFront();
481477
}
482478

483479

@@ -545,7 +541,7 @@ public void print_frontRear() {
545541
System.out.println("Front of the queue:" + front.data
546542
+ " Rear of the queue:" + rear.data);
547543
}
548-
public static void main(String a[]){
544+
public static void main(String[] a){
549545

550546
LinkedListQueue queue = new LinkedListQueue();
551547

src/main/java/datastructures/DeleteDuplicateLinkedList.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public static void display(Node head)
7070
}
7171
}
7272

73-
public static void main(String args[])
73+
public static void main(String[] args)
7474
{
7575
// Scanner sc=new Scanner(System.in);
7676
Node head=null;

src/main/java/datastructures/DoublyLinkedList.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ static class Node{
6363
int data;
6464
Node next;
6565
Node prev;
66-
};
66+
}
6767

6868
static Node head=null;
6969

@@ -109,7 +109,7 @@ static void printNodes() {
109109
System.out.printf("%d ", temp.data);
110110

111111
//traverse in backward direction starting from last node
112-
System.out.printf("\nCircular doubly linked list travesed backward: \n");
112+
System.out.print("\nCircular doubly linked list travesed backward: \n");
113113
Node last = head.prev;
114114
temp = last;
115115
while (temp.prev != last)
@@ -148,14 +148,14 @@ public static void cdllImpl()
148148
CircularDoublyLinkedList cdl_List = new CircularDoublyLinkedList();
149149

150150
// add nodes to the list
151-
cdl_List.addNode(40);
152-
cdl_List.addNode(50);
153-
cdl_List.addNode(60);
154-
cdl_List.addNode(70);
155-
cdl_List.addNode(80);
151+
CircularDoublyLinkedList.addNode(40);
152+
CircularDoublyLinkedList.addNode(50);
153+
CircularDoublyLinkedList.addNode(60);
154+
CircularDoublyLinkedList.addNode(70);
155+
CircularDoublyLinkedList.addNode(80);
156156

157157
//print the list
158-
System.out.printf("Circular doubly linked list: ");
159-
cdl_List.printNodes();
158+
System.out.print("Circular doubly linked list: ");
159+
CircularDoublyLinkedList.printNodes();
160160
}
161161
}

0 commit comments

Comments
 (0)