mirror of
https://github.com/TheAlgorithms/Java.git
synced 2026-03-13 08:40:43 +08:00
General performance improvement (#6078)
This commit is contained in:
committed by
GitHub
parent
7b962a4a1d
commit
df0c997e4b
@@ -42,9 +42,7 @@ public class FloydWarshall {
|
||||
public void floydwarshall(int[][] adjacencyMatrix) {
|
||||
// Initialize the distance matrix with the adjacency matrix.
|
||||
for (int source = 1; source <= numberofvertices; source++) {
|
||||
for (int destination = 1; destination <= numberofvertices; destination++) {
|
||||
distanceMatrix[source][destination] = adjacencyMatrix[source][destination];
|
||||
}
|
||||
System.arraycopy(adjacencyMatrix[source], 1, distanceMatrix[source], 1, numberofvertices);
|
||||
}
|
||||
for (int intermediate = 1; intermediate <= numberofvertices; intermediate++) {
|
||||
for (int source = 1; source <= numberofvertices; source++) {
|
||||
|
||||
@@ -403,7 +403,7 @@ public class SinglyLinkedList implements Iterable<Integer> {
|
||||
SinglyLinkedList list = new SinglyLinkedList();
|
||||
assert list.isEmpty();
|
||||
assert list.size() == 0 && list.count() == 0;
|
||||
assert list.toString().equals("");
|
||||
assert list.toString().isEmpty();
|
||||
|
||||
/* Test insert function */
|
||||
list.insertHead(5);
|
||||
|
||||
@@ -23,6 +23,7 @@ public class GenericTree {
|
||||
}
|
||||
|
||||
private final Node root;
|
||||
|
||||
public GenericTree() { // Constructor
|
||||
Scanner scn = new Scanner(System.in);
|
||||
root = createTreeG(null, 0, scn);
|
||||
@@ -225,8 +226,6 @@ public class GenericTree {
|
||||
for (int i = 0; i < node.child.size(); i++) {
|
||||
if (node.child.get(i).child.size() == 0) {
|
||||
arr.add(i);
|
||||
// node.child.remove(i);
|
||||
// i--;
|
||||
} else {
|
||||
removeleaves(node.child.get(i));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user