General performance improvement (#6078)

This commit is contained in:
Strange Developer
2024-11-01 18:52:42 +01:00
committed by GitHub
parent 7b962a4a1d
commit df0c997e4b
29 changed files with 92 additions and 75 deletions

View File

@@ -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++) {

View File

@@ -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);

View File

@@ -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));
}