Skip to content

Commit b02bc05

Browse files
committed
Some Stuff
1 parent 9a6aef5 commit b02bc05

File tree

8 files changed

+26
-12
lines changed

8 files changed

+26
-12
lines changed

README.md

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
# Algorithms
22

3-
A collection of common algorithms and data structures with source code in Java, C++, and Python.
4-
5-
If you want to view the Java source code, go to java.md. If you want to view the Python source code, go to python.md, and same for C++ except go to cpp.md.
3+
A collection of common algorithms and data structures with source code in Java.
64

75
# Gradle
86

src/main/java/bitmanipulation/problems/missingnumber/MissingNumber.java

+10-3
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,21 @@
22

33
public class MissingNumber {
44

5+
/**
6+
* Given an array nums containing n distinct numbers in the range [0, n], return the only number
7+
* in the range that is missing from the array.
8+
*
9+
* @param arr Array of numbers.
10+
* @return The single number that is missing from the array.
11+
*/
512
public static int missingNumber(int[] arr) {
6-
int XOR = 0;
13+
int xor = 0;
714

815
for (int i = 0; i < arr.length; i++) {
9-
XOR ^= i ^ arr[i];
16+
xor ^= i ^ arr[i];
1017
}
1118

12-
return XOR ^ arr.length;
19+
return xor ^ arr.length;
1320
}
1421

1522
public static void main(String[] args) {

src/main/java/bitmanipulation/problems/singlenumber/SingleNumber.java

+8
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22

33
public class SingleNumber {
44

5+
/**
6+
* Given a non-empty array of integers nums, every element appears twice except for one. Find that
7+
* single one. You must implement a solution in linear runtime complexity and use only constant
8+
* extra space.
9+
*
10+
* @param arr Array of integers.
11+
* @return The element that only appears once.
12+
*/
513
public static int singleNumber(int[] arr) {
614
int xor = 0;
715

src/main/java/datastructures/unionfind/UnionFind.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ public boolean sameGroup(int element1, int element2) {
7878
* @return True if the {@link UnionFind} is path compressed.
7979
*/
8080
public boolean isPathCompressed() {
81-
for (int j : parent) {
82-
if (j != parent[j]) {
81+
for (int i = 0; i < parent.length; i++) {
82+
if (parent[i] != parent[parent[i]]) {
8383
return false;
8484
}
8585
}

src/main/java/graphtheory/shortestpathalgorithms/singlesource/dijkstrasshortestpath/DijkstrasShortestPath.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package graphtheory.shortestpathalgorithms.singlesource.dijkstrasshortestpath;
22

3-
import datastructures.minpriorityqueue.MinHeap.MinHeap;
3+
import datastructures.minpriorityqueue.minheap.MinHeap;
44
import java.util.Arrays;
55
import java.util.Comparator;
66
import java.util.LinkedList;

src/main/java/math/vectors/Vector3.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ public double dotProduct(final Vector3 other) {
7070
}
7171

7272
public Vector3 crossProduct(final Vector3 other) {
73-
return new Vector3(y * other.z - z * other.y, z * other.x - x * other.z, x * other.y - y * other.x);
73+
return new Vector3(
74+
y * other.z - z * other.y, z * other.x - x * other.z, x * other.y - y * other.x);
7475
}
7576

7677
public double norm() {

src/test/java/datastructures/minpriorityqueue/FibonacciHeapTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import static org.junit.jupiter.api.Assertions.*;
44

5-
import datastructures.minpriorityqueue.FibonacciHeap.FibonacciHeap;
5+
import datastructures.minpriorityqueue.fibonacciheap.FibonacciHeap;
66
import java.util.Arrays;
77
import org.junit.jupiter.api.Disabled;
88
import org.junit.jupiter.api.Test;

src/test/java/datastructures/minpriorityqueue/MinHeapTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import static org.junit.jupiter.api.Assertions.*;
44

5-
import datastructures.minpriorityqueue.MinHeap.MinHeap;
5+
import datastructures.minpriorityqueue.minheap.MinHeap;
66
import java.util.Arrays;
77
import java.util.HashSet;
88
import java.util.PriorityQueue;

0 commit comments

Comments
 (0)