diff --git a/.gitignore b/.gitignore
index 7fe2778755..0e71421ee7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -63,4 +63,6 @@ jmeter/src/main/resources/*-JMeter.csv
**/tmp
**/out-tsc
**/nbproject/
-**/nb-configuration.xml
\ No newline at end of file
+**/nb-configuration.xml
+core-scala/.cache-main
+core-scala/.cache-tests
diff --git a/spring-custom-aop/.gitignore b/algorithms-genetic/.gitignore
similarity index 77%
rename from spring-custom-aop/.gitignore
rename to algorithms-genetic/.gitignore
index 60be5b80aa..30b2b7442c 100644
--- a/spring-custom-aop/.gitignore
+++ b/algorithms-genetic/.gitignore
@@ -1,4 +1,4 @@
/target/
.settings/
.classpath
-.project
+.project
\ No newline at end of file
diff --git a/algorithms-genetic/README.md b/algorithms-genetic/README.md
new file mode 100644
index 0000000000..0f68918fff
--- /dev/null
+++ b/algorithms-genetic/README.md
@@ -0,0 +1,4 @@
+## Relevant articles:
+
+- [Introduction to Jenetics Library](http://www.baeldung.com/jenetics)
+- [Ant Colony Optimization](http://www.baeldung.com/java-ant-colony-optimization)
\ No newline at end of file
diff --git a/algorithms-genetic/pom.xml b/algorithms-genetic/pom.xml
new file mode 100644
index 0000000000..2a10a81980
--- /dev/null
+++ b/algorithms-genetic/pom.xml
@@ -0,0 +1,64 @@
+
+ 4.0.0
+ com.baeldung
+ algorithms-genetic
+ 0.0.1-SNAPSHOT
+
+
+ com.baeldung
+ parent-modules
+ 1.0.0-SNAPSHOT
+
+
+
+
+ org.apache.commons
+ commons-math3
+ ${commons-math3.version}
+
+
+ commons-codec
+ commons-codec
+ ${commons-codec.version}
+
+
+ org.projectlombok
+ lombok
+ ${lombok.version}
+ provided
+
+
+ io.jenetics
+ jenetics
+ ${io.jenetics.version}
+
+
+ org.assertj
+ assertj-core
+ ${org.assertj.core.version}
+ test
+
+
+
+
+
+
+
+ org.codehaus.mojo
+ exec-maven-plugin
+ ${exec-maven-plugin.version}
+
+
+
+
+
+
+ 1.16.12
+ 3.6.1
+ 3.7.0
+ 3.9.0
+ 1.11
+
+
+
\ No newline at end of file
diff --git a/algorithms/roundUpToHundred/.gitignore b/algorithms-genetic/roundUpToHundred/.gitignore
similarity index 100%
rename from algorithms/roundUpToHundred/.gitignore
rename to algorithms-genetic/roundUpToHundred/.gitignore
diff --git a/algorithms/roundUpToHundred/src/com/java/src/RoundUpToHundred.java b/algorithms-genetic/roundUpToHundred/src/com/java/src/RoundUpToHundred.java
similarity index 95%
rename from algorithms/roundUpToHundred/src/com/java/src/RoundUpToHundred.java
rename to algorithms-genetic/roundUpToHundred/src/com/java/src/RoundUpToHundred.java
index f5024c227d..6c02a340d3 100644
--- a/algorithms/roundUpToHundred/src/com/java/src/RoundUpToHundred.java
+++ b/algorithms-genetic/roundUpToHundred/src/com/java/src/RoundUpToHundred.java
@@ -1,20 +1,20 @@
-package com.java.src;
-
-import java.util.Scanner;
-
-public class RoundUpToHundred {
-
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- double input = scanner.nextDouble();
- scanner.close();
-
- RoundUpToHundred.round(input);
- }
-
- static long round(double input) {
- long i = (long) Math.ceil(input);
- return ((i + 99) / 100) * 100;
- };
-
-}
+package com.java.src;
+
+import java.util.Scanner;
+
+public class RoundUpToHundred {
+
+ public static void main(String[] args) {
+ Scanner scanner = new Scanner(System.in);
+ double input = scanner.nextDouble();
+ scanner.close();
+
+ RoundUpToHundred.round(input);
+ }
+
+ static long round(double input) {
+ long i = (long) Math.ceil(input);
+ return ((i + 99) / 100) * 100;
+ };
+
+}
diff --git a/algorithms/roundUpToHundred/src/com/java/src/RoundUpToHundredTest.java b/algorithms-genetic/roundUpToHundred/src/com/java/src/RoundUpToHundredTest.java
similarity index 97%
rename from algorithms/roundUpToHundred/src/com/java/src/RoundUpToHundredTest.java
rename to algorithms-genetic/roundUpToHundred/src/com/java/src/RoundUpToHundredTest.java
index f35a9a249f..cb541ad49c 100644
--- a/algorithms/roundUpToHundred/src/com/java/src/RoundUpToHundredTest.java
+++ b/algorithms-genetic/roundUpToHundred/src/com/java/src/RoundUpToHundredTest.java
@@ -1,14 +1,14 @@
-package com.java.src;
-
-import static org.junit.Assert.assertEquals;
-
-import org.junit.Test;
-
-public class RoundUpToHundredTest {
- @Test
- public void givenInput_whenRound_thenRoundUpToTheNearestHundred() {
- assertEquals("Rounded up to hundred", 100, RoundUpToHundred.round(99));
- assertEquals("Rounded up to three hundred ", 300, RoundUpToHundred.round(200.2));
- assertEquals("Returns same rounded value", 400, RoundUpToHundred.round(400));
- }
-}
+package com.java.src;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+
+public class RoundUpToHundredTest {
+ @Test
+ public void givenInput_whenRound_thenRoundUpToTheNearestHundred() {
+ assertEquals("Rounded up to hundred", 100, RoundUpToHundred.round(99));
+ assertEquals("Rounded up to three hundred ", 300, RoundUpToHundred.round(200.2));
+ assertEquals("Returns same rounded value", 400, RoundUpToHundred.round(400));
+ }
+}
diff --git a/algorithms/src/main/java/com/baeldung/algorithms/RunAlgorithm.java b/algorithms-genetic/src/main/java/com/baeldung/algorithms/RunAlgorithm.java
similarity index 100%
rename from algorithms/src/main/java/com/baeldung/algorithms/RunAlgorithm.java
rename to algorithms-genetic/src/main/java/com/baeldung/algorithms/RunAlgorithm.java
diff --git a/algorithms/src/main/java/com/baeldung/algorithms/ga/annealing/City.java b/algorithms-genetic/src/main/java/com/baeldung/algorithms/ga/annealing/City.java
similarity index 100%
rename from algorithms/src/main/java/com/baeldung/algorithms/ga/annealing/City.java
rename to algorithms-genetic/src/main/java/com/baeldung/algorithms/ga/annealing/City.java
diff --git a/algorithms/src/main/java/com/baeldung/algorithms/ga/annealing/SimulatedAnnealing.java b/algorithms-genetic/src/main/java/com/baeldung/algorithms/ga/annealing/SimulatedAnnealing.java
similarity index 100%
rename from algorithms/src/main/java/com/baeldung/algorithms/ga/annealing/SimulatedAnnealing.java
rename to algorithms-genetic/src/main/java/com/baeldung/algorithms/ga/annealing/SimulatedAnnealing.java
diff --git a/algorithms/src/main/java/com/baeldung/algorithms/ga/annealing/Travel.java b/algorithms-genetic/src/main/java/com/baeldung/algorithms/ga/annealing/Travel.java
similarity index 100%
rename from algorithms/src/main/java/com/baeldung/algorithms/ga/annealing/Travel.java
rename to algorithms-genetic/src/main/java/com/baeldung/algorithms/ga/annealing/Travel.java
diff --git a/algorithms/src/main/java/com/baeldung/algorithms/ga/ant_colony/Ant.java b/algorithms-genetic/src/main/java/com/baeldung/algorithms/ga/ant_colony/Ant.java
similarity index 100%
rename from algorithms/src/main/java/com/baeldung/algorithms/ga/ant_colony/Ant.java
rename to algorithms-genetic/src/main/java/com/baeldung/algorithms/ga/ant_colony/Ant.java
diff --git a/algorithms/src/main/java/com/baeldung/algorithms/ga/ant_colony/AntColonyOptimization.java b/algorithms-genetic/src/main/java/com/baeldung/algorithms/ga/ant_colony/AntColonyOptimization.java
similarity index 100%
rename from algorithms/src/main/java/com/baeldung/algorithms/ga/ant_colony/AntColonyOptimization.java
rename to algorithms-genetic/src/main/java/com/baeldung/algorithms/ga/ant_colony/AntColonyOptimization.java
diff --git a/algorithms/src/main/java/com/baeldung/algorithms/ga/binary/Individual.java b/algorithms-genetic/src/main/java/com/baeldung/algorithms/ga/binary/Individual.java
similarity index 100%
rename from algorithms/src/main/java/com/baeldung/algorithms/ga/binary/Individual.java
rename to algorithms-genetic/src/main/java/com/baeldung/algorithms/ga/binary/Individual.java
diff --git a/algorithms/src/main/java/com/baeldung/algorithms/ga/binary/Population.java b/algorithms-genetic/src/main/java/com/baeldung/algorithms/ga/binary/Population.java
similarity index 100%
rename from algorithms/src/main/java/com/baeldung/algorithms/ga/binary/Population.java
rename to algorithms-genetic/src/main/java/com/baeldung/algorithms/ga/binary/Population.java
diff --git a/algorithms/src/main/java/com/baeldung/algorithms/ga/binary/SimpleGeneticAlgorithm.java b/algorithms-genetic/src/main/java/com/baeldung/algorithms/ga/binary/SimpleGeneticAlgorithm.java
similarity index 100%
rename from algorithms/src/main/java/com/baeldung/algorithms/ga/binary/SimpleGeneticAlgorithm.java
rename to algorithms-genetic/src/main/java/com/baeldung/algorithms/ga/binary/SimpleGeneticAlgorithm.java
diff --git a/algorithms/src/main/java/com/baeldung/algorithms/ga/dijkstra/Dijkstra.java b/algorithms-genetic/src/main/java/com/baeldung/algorithms/ga/dijkstra/Dijkstra.java
similarity index 100%
rename from algorithms/src/main/java/com/baeldung/algorithms/ga/dijkstra/Dijkstra.java
rename to algorithms-genetic/src/main/java/com/baeldung/algorithms/ga/dijkstra/Dijkstra.java
diff --git a/algorithms/src/main/java/com/baeldung/algorithms/ga/dijkstra/Graph.java b/algorithms-genetic/src/main/java/com/baeldung/algorithms/ga/dijkstra/Graph.java
similarity index 100%
rename from algorithms/src/main/java/com/baeldung/algorithms/ga/dijkstra/Graph.java
rename to algorithms-genetic/src/main/java/com/baeldung/algorithms/ga/dijkstra/Graph.java
diff --git a/algorithms/src/main/java/com/baeldung/algorithms/ga/dijkstra/Node.java b/algorithms-genetic/src/main/java/com/baeldung/algorithms/ga/dijkstra/Node.java
similarity index 100%
rename from algorithms/src/main/java/com/baeldung/algorithms/ga/dijkstra/Node.java
rename to algorithms-genetic/src/main/java/com/baeldung/algorithms/ga/dijkstra/Node.java
diff --git a/algorithms/src/main/java/com/baeldung/algorithms/ga/jenetics/Knapsack.java b/algorithms-genetic/src/main/java/com/baeldung/algorithms/ga/jenetics/Knapsack.java
similarity index 100%
rename from algorithms/src/main/java/com/baeldung/algorithms/ga/jenetics/Knapsack.java
rename to algorithms-genetic/src/main/java/com/baeldung/algorithms/ga/jenetics/Knapsack.java
diff --git a/algorithms/src/main/java/com/baeldung/algorithms/ga/jenetics/KnapsackFF.java b/algorithms-genetic/src/main/java/com/baeldung/algorithms/ga/jenetics/KnapsackFF.java
similarity index 100%
rename from algorithms/src/main/java/com/baeldung/algorithms/ga/jenetics/KnapsackFF.java
rename to algorithms-genetic/src/main/java/com/baeldung/algorithms/ga/jenetics/KnapsackFF.java
diff --git a/algorithms/src/main/java/com/baeldung/algorithms/ga/jenetics/KnapsackItem.java b/algorithms-genetic/src/main/java/com/baeldung/algorithms/ga/jenetics/KnapsackItem.java
similarity index 100%
rename from algorithms/src/main/java/com/baeldung/algorithms/ga/jenetics/KnapsackItem.java
rename to algorithms-genetic/src/main/java/com/baeldung/algorithms/ga/jenetics/KnapsackItem.java
diff --git a/algorithms/src/main/java/com/baeldung/algorithms/ga/jenetics/SimpleGeneticAlgorithm.java b/algorithms-genetic/src/main/java/com/baeldung/algorithms/ga/jenetics/SimpleGeneticAlgorithm.java
similarity index 100%
rename from algorithms/src/main/java/com/baeldung/algorithms/ga/jenetics/SimpleGeneticAlgorithm.java
rename to algorithms-genetic/src/main/java/com/baeldung/algorithms/ga/jenetics/SimpleGeneticAlgorithm.java
diff --git a/algorithms/src/main/java/com/baeldung/algorithms/ga/jenetics/SpringsteenProblem.java b/algorithms-genetic/src/main/java/com/baeldung/algorithms/ga/jenetics/SpringsteenProblem.java
similarity index 100%
rename from algorithms/src/main/java/com/baeldung/algorithms/ga/jenetics/SpringsteenProblem.java
rename to algorithms-genetic/src/main/java/com/baeldung/algorithms/ga/jenetics/SpringsteenProblem.java
diff --git a/algorithms/src/main/java/com/baeldung/algorithms/ga/jenetics/SpringsteenRecord.java b/algorithms-genetic/src/main/java/com/baeldung/algorithms/ga/jenetics/SpringsteenRecord.java
similarity index 100%
rename from algorithms/src/main/java/com/baeldung/algorithms/ga/jenetics/SpringsteenRecord.java
rename to algorithms-genetic/src/main/java/com/baeldung/algorithms/ga/jenetics/SpringsteenRecord.java
diff --git a/algorithms/src/main/java/com/baeldung/algorithms/ga/jenetics/SubsetSum.java b/algorithms-genetic/src/main/java/com/baeldung/algorithms/ga/jenetics/SubsetSum.java
similarity index 100%
rename from algorithms/src/main/java/com/baeldung/algorithms/ga/jenetics/SubsetSum.java
rename to algorithms-genetic/src/main/java/com/baeldung/algorithms/ga/jenetics/SubsetSum.java
diff --git a/algorithms/src/main/java/com/baeldung/algorithms/ga/jenetics/TravelingSalesman.java b/algorithms-genetic/src/main/java/com/baeldung/algorithms/ga/jenetics/TravelingSalesman.java
similarity index 100%
rename from algorithms/src/main/java/com/baeldung/algorithms/ga/jenetics/TravelingSalesman.java
rename to algorithms-genetic/src/main/java/com/baeldung/algorithms/ga/jenetics/TravelingSalesman.java
diff --git a/algorithms/src/main/java/com/baeldung/algorithms/slope_one/InputData.java b/algorithms-genetic/src/main/java/com/baeldung/algorithms/slope_one/InputData.java
similarity index 100%
rename from algorithms/src/main/java/com/baeldung/algorithms/slope_one/InputData.java
rename to algorithms-genetic/src/main/java/com/baeldung/algorithms/slope_one/InputData.java
diff --git a/algorithms/src/main/java/com/baeldung/algorithms/slope_one/Item.java b/algorithms-genetic/src/main/java/com/baeldung/algorithms/slope_one/Item.java
similarity index 100%
rename from algorithms/src/main/java/com/baeldung/algorithms/slope_one/Item.java
rename to algorithms-genetic/src/main/java/com/baeldung/algorithms/slope_one/Item.java
diff --git a/algorithms/src/main/java/com/baeldung/algorithms/slope_one/SlopeOne.java b/algorithms-genetic/src/main/java/com/baeldung/algorithms/slope_one/SlopeOne.java
similarity index 100%
rename from algorithms/src/main/java/com/baeldung/algorithms/slope_one/SlopeOne.java
rename to algorithms-genetic/src/main/java/com/baeldung/algorithms/slope_one/SlopeOne.java
diff --git a/algorithms/src/main/java/com/baeldung/algorithms/slope_one/User.java b/algorithms-genetic/src/main/java/com/baeldung/algorithms/slope_one/User.java
similarity index 100%
rename from algorithms/src/main/java/com/baeldung/algorithms/slope_one/User.java
rename to algorithms-genetic/src/main/java/com/baeldung/algorithms/slope_one/User.java
diff --git a/activejdbc/src/main/resources/logback.xml b/algorithms-genetic/src/main/resources/logback.xml
similarity index 100%
rename from activejdbc/src/main/resources/logback.xml
rename to algorithms-genetic/src/main/resources/logback.xml
diff --git a/algorithms/src/test/java/com/baeldung/algorithms/AntColonyOptimizationLongRunningUnitTest.java b/algorithms-genetic/src/test/java/com/baeldung/algorithms/AntColonyOptimizationLongRunningUnitTest.java
similarity index 100%
rename from algorithms/src/test/java/com/baeldung/algorithms/AntColonyOptimizationLongRunningUnitTest.java
rename to algorithms-genetic/src/test/java/com/baeldung/algorithms/AntColonyOptimizationLongRunningUnitTest.java
diff --git a/algorithms/src/test/java/com/baeldung/algorithms/BinaryGeneticAlgorithmLongRunningUnitTest.java b/algorithms-genetic/src/test/java/com/baeldung/algorithms/BinaryGeneticAlgorithmLongRunningUnitTest.java
similarity index 100%
rename from algorithms/src/test/java/com/baeldung/algorithms/BinaryGeneticAlgorithmLongRunningUnitTest.java
rename to algorithms-genetic/src/test/java/com/baeldung/algorithms/BinaryGeneticAlgorithmLongRunningUnitTest.java
diff --git a/algorithms/src/test/java/com/baeldung/algorithms/DijkstraAlgorithmLongRunningUnitTest.java b/algorithms-genetic/src/test/java/com/baeldung/algorithms/DijkstraAlgorithmLongRunningUnitTest.java
similarity index 100%
rename from algorithms/src/test/java/com/baeldung/algorithms/DijkstraAlgorithmLongRunningUnitTest.java
rename to algorithms-genetic/src/test/java/com/baeldung/algorithms/DijkstraAlgorithmLongRunningUnitTest.java
diff --git a/algorithms/src/test/java/com/baeldung/algorithms/SimulatedAnnealingLongRunningUnitTest.java b/algorithms-genetic/src/test/java/com/baeldung/algorithms/SimulatedAnnealingLongRunningUnitTest.java
similarity index 100%
rename from algorithms/src/test/java/com/baeldung/algorithms/SimulatedAnnealingLongRunningUnitTest.java
rename to algorithms-genetic/src/test/java/com/baeldung/algorithms/SimulatedAnnealingLongRunningUnitTest.java
diff --git a/algorithms-miscellaneous-1/.gitignore b/algorithms-miscellaneous-1/.gitignore
new file mode 100644
index 0000000000..30b2b7442c
--- /dev/null
+++ b/algorithms-miscellaneous-1/.gitignore
@@ -0,0 +1,4 @@
+/target/
+.settings/
+.classpath
+.project
\ No newline at end of file
diff --git a/algorithms-miscellaneous-1/README.md b/algorithms-miscellaneous-1/README.md
new file mode 100644
index 0000000000..9efb2233bf
--- /dev/null
+++ b/algorithms-miscellaneous-1/README.md
@@ -0,0 +1,12 @@
+## Relevant articles:
+
+- [Validating Input With Finite Automata in Java](http://www.baeldung.com/java-finite-automata)
+- [Example of Hill Climbing Algorithm](http://www.baeldung.com/java-hill-climbing-algorithm)
+- [Monte Carlo Tree Search for Tic-Tac-Toe Game](http://www.baeldung.com/java-monte-carlo-tree-search)
+- [Binary Search Algorithm in Java](http://www.baeldung.com/java-binary-search)
+- [Introduction to Minimax Algorithm](http://www.baeldung.com/java-minimax-algorithm)
+- [How to Calculate Levenshtein Distance in Java?](http://www.baeldung.com/java-levenshtein-distance)
+- [How to Find the Kth Largest Element in Java](http://www.baeldung.com/java-kth-largest-element)
+- [Multi-Swarm Optimization Algorithm in Java](http://www.baeldung.com/java-multi-swarm-algorithm)
+- [String Search Algorithms for Large Texts](http://www.baeldung.com/java-full-text-search-algorithms)
+- [Check If a String Contains All The Letters of The Alphabet](https://www.baeldung.com/java-string-contains-all-letters)
\ No newline at end of file
diff --git a/algorithms-miscellaneous-1/pom.xml b/algorithms-miscellaneous-1/pom.xml
new file mode 100644
index 0000000000..16749d452e
--- /dev/null
+++ b/algorithms-miscellaneous-1/pom.xml
@@ -0,0 +1,78 @@
+
+ 4.0.0
+ com.baeldung
+ algorithms-miscellaneous-1
+ 0.0.1-SNAPSHOT
+
+
+ com.baeldung
+ parent-modules
+ 1.0.0-SNAPSHOT
+
+
+
+
+ org.apache.commons
+ commons-math3
+ ${commons-math3.version}
+
+
+ commons-codec
+ commons-codec
+ ${commons-codec.version}
+
+
+ org.projectlombok
+ lombok
+ ${lombok.version}
+ provided
+
+
+ org.assertj
+ assertj-core
+ ${org.assertj.core.version}
+ test
+
+
+
+
+
+
+
+ org.codehaus.mojo
+ exec-maven-plugin
+ ${exec-maven-plugin.version}
+
+
+
+
+
+
+
+
+ org.codehaus.mojo
+ cobertura-maven-plugin
+ 2.7
+
+
+
+ com/baeldung/algorithms/dijkstra/*
+
+
+ com/baeldung/algorithms/dijkstra/*
+
+
+
+
+
+
+
+
+ 1.16.12
+ 3.6.1
+ 3.9.0
+ 1.11
+
+
+
\ No newline at end of file
diff --git a/algorithms-miscellaneous-1/roundUpToHundred/.gitignore b/algorithms-miscellaneous-1/roundUpToHundred/.gitignore
new file mode 100644
index 0000000000..ae3c172604
--- /dev/null
+++ b/algorithms-miscellaneous-1/roundUpToHundred/.gitignore
@@ -0,0 +1 @@
+/bin/
diff --git a/algorithms-miscellaneous-1/roundUpToHundred/src/com/java/src/RoundUpToHundred.java b/algorithms-miscellaneous-1/roundUpToHundred/src/com/java/src/RoundUpToHundred.java
new file mode 100644
index 0000000000..6c02a340d3
--- /dev/null
+++ b/algorithms-miscellaneous-1/roundUpToHundred/src/com/java/src/RoundUpToHundred.java
@@ -0,0 +1,20 @@
+package com.java.src;
+
+import java.util.Scanner;
+
+public class RoundUpToHundred {
+
+ public static void main(String[] args) {
+ Scanner scanner = new Scanner(System.in);
+ double input = scanner.nextDouble();
+ scanner.close();
+
+ RoundUpToHundred.round(input);
+ }
+
+ static long round(double input) {
+ long i = (long) Math.ceil(input);
+ return ((i + 99) / 100) * 100;
+ };
+
+}
diff --git a/algorithms-miscellaneous-1/roundUpToHundred/src/com/java/src/RoundUpToHundredTest.java b/algorithms-miscellaneous-1/roundUpToHundred/src/com/java/src/RoundUpToHundredTest.java
new file mode 100644
index 0000000000..cb541ad49c
--- /dev/null
+++ b/algorithms-miscellaneous-1/roundUpToHundred/src/com/java/src/RoundUpToHundredTest.java
@@ -0,0 +1,14 @@
+package com.java.src;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+
+public class RoundUpToHundredTest {
+ @Test
+ public void givenInput_whenRound_thenRoundUpToTheNearestHundred() {
+ assertEquals("Rounded up to hundred", 100, RoundUpToHundred.round(99));
+ assertEquals("Rounded up to three hundred ", 300, RoundUpToHundred.round(200.2));
+ assertEquals("Returns same rounded value", 400, RoundUpToHundred.round(400));
+ }
+}
diff --git a/algorithms/src/main/java/com/baeldung/algorithms/automata/FiniteStateMachine.java b/algorithms-miscellaneous-1/src/main/java/com/baeldung/algorithms/automata/FiniteStateMachine.java
similarity index 100%
rename from algorithms/src/main/java/com/baeldung/algorithms/automata/FiniteStateMachine.java
rename to algorithms-miscellaneous-1/src/main/java/com/baeldung/algorithms/automata/FiniteStateMachine.java
diff --git a/algorithms/src/main/java/com/baeldung/algorithms/automata/RtFiniteStateMachine.java b/algorithms-miscellaneous-1/src/main/java/com/baeldung/algorithms/automata/RtFiniteStateMachine.java
similarity index 100%
rename from algorithms/src/main/java/com/baeldung/algorithms/automata/RtFiniteStateMachine.java
rename to algorithms-miscellaneous-1/src/main/java/com/baeldung/algorithms/automata/RtFiniteStateMachine.java
diff --git a/algorithms/src/main/java/com/baeldung/algorithms/automata/RtState.java b/algorithms-miscellaneous-1/src/main/java/com/baeldung/algorithms/automata/RtState.java
similarity index 100%
rename from algorithms/src/main/java/com/baeldung/algorithms/automata/RtState.java
rename to algorithms-miscellaneous-1/src/main/java/com/baeldung/algorithms/automata/RtState.java
diff --git a/algorithms/src/main/java/com/baeldung/algorithms/automata/RtTransition.java b/algorithms-miscellaneous-1/src/main/java/com/baeldung/algorithms/automata/RtTransition.java
similarity index 100%
rename from algorithms/src/main/java/com/baeldung/algorithms/automata/RtTransition.java
rename to algorithms-miscellaneous-1/src/main/java/com/baeldung/algorithms/automata/RtTransition.java
diff --git a/algorithms/src/main/java/com/baeldung/algorithms/automata/State.java b/algorithms-miscellaneous-1/src/main/java/com/baeldung/algorithms/automata/State.java
similarity index 100%
rename from algorithms/src/main/java/com/baeldung/algorithms/automata/State.java
rename to algorithms-miscellaneous-1/src/main/java/com/baeldung/algorithms/automata/State.java
diff --git a/algorithms/src/main/java/com/baeldung/algorithms/automata/Transition.java b/algorithms-miscellaneous-1/src/main/java/com/baeldung/algorithms/automata/Transition.java
similarity index 100%
rename from algorithms/src/main/java/com/baeldung/algorithms/automata/Transition.java
rename to algorithms-miscellaneous-1/src/main/java/com/baeldung/algorithms/automata/Transition.java
diff --git a/algorithms/src/main/java/com/baeldung/algorithms/binarysearch/BinarySearch.java b/algorithms-miscellaneous-1/src/main/java/com/baeldung/algorithms/binarysearch/BinarySearch.java
similarity index 100%
rename from algorithms/src/main/java/com/baeldung/algorithms/binarysearch/BinarySearch.java
rename to algorithms-miscellaneous-1/src/main/java/com/baeldung/algorithms/binarysearch/BinarySearch.java
diff --git a/algorithms/src/main/java/com/baeldung/algorithms/hillclimbing/HillClimbing.java b/algorithms-miscellaneous-1/src/main/java/com/baeldung/algorithms/hillclimbing/HillClimbing.java
similarity index 100%
rename from algorithms/src/main/java/com/baeldung/algorithms/hillclimbing/HillClimbing.java
rename to algorithms-miscellaneous-1/src/main/java/com/baeldung/algorithms/hillclimbing/HillClimbing.java
diff --git a/algorithms/src/main/java/com/baeldung/algorithms/hillclimbing/State.java b/algorithms-miscellaneous-1/src/main/java/com/baeldung/algorithms/hillclimbing/State.java
similarity index 100%
rename from algorithms/src/main/java/com/baeldung/algorithms/hillclimbing/State.java
rename to algorithms-miscellaneous-1/src/main/java/com/baeldung/algorithms/hillclimbing/State.java
diff --git a/algorithms/src/main/java/com/baeldung/algorithms/kthlargest/FindKthLargest.java b/algorithms-miscellaneous-1/src/main/java/com/baeldung/algorithms/kthlargest/FindKthLargest.java
similarity index 100%
rename from algorithms/src/main/java/com/baeldung/algorithms/kthlargest/FindKthLargest.java
rename to algorithms-miscellaneous-1/src/main/java/com/baeldung/algorithms/kthlargest/FindKthLargest.java
diff --git a/algorithms/src/main/java/com/baeldung/algorithms/linesintersection/LinesIntersectionService.java b/algorithms-miscellaneous-1/src/main/java/com/baeldung/algorithms/linesintersection/LinesIntersectionService.java
similarity index 100%
rename from algorithms/src/main/java/com/baeldung/algorithms/linesintersection/LinesIntersectionService.java
rename to algorithms-miscellaneous-1/src/main/java/com/baeldung/algorithms/linesintersection/LinesIntersectionService.java
diff --git a/algorithms/src/main/java/com/baeldung/algorithms/mcts/montecarlo/MonteCarloTreeSearch.java b/algorithms-miscellaneous-1/src/main/java/com/baeldung/algorithms/mcts/montecarlo/MonteCarloTreeSearch.java
similarity index 100%
rename from algorithms/src/main/java/com/baeldung/algorithms/mcts/montecarlo/MonteCarloTreeSearch.java
rename to algorithms-miscellaneous-1/src/main/java/com/baeldung/algorithms/mcts/montecarlo/MonteCarloTreeSearch.java
diff --git a/algorithms/src/main/java/com/baeldung/algorithms/mcts/montecarlo/State.java b/algorithms-miscellaneous-1/src/main/java/com/baeldung/algorithms/mcts/montecarlo/State.java
similarity index 100%
rename from algorithms/src/main/java/com/baeldung/algorithms/mcts/montecarlo/State.java
rename to algorithms-miscellaneous-1/src/main/java/com/baeldung/algorithms/mcts/montecarlo/State.java
diff --git a/algorithms/src/main/java/com/baeldung/algorithms/mcts/montecarlo/UCT.java b/algorithms-miscellaneous-1/src/main/java/com/baeldung/algorithms/mcts/montecarlo/UCT.java
similarity index 100%
rename from algorithms/src/main/java/com/baeldung/algorithms/mcts/montecarlo/UCT.java
rename to algorithms-miscellaneous-1/src/main/java/com/baeldung/algorithms/mcts/montecarlo/UCT.java
diff --git a/algorithms/src/main/java/com/baeldung/algorithms/mcts/tictactoe/Board.java b/algorithms-miscellaneous-1/src/main/java/com/baeldung/algorithms/mcts/tictactoe/Board.java
similarity index 100%
rename from algorithms/src/main/java/com/baeldung/algorithms/mcts/tictactoe/Board.java
rename to algorithms-miscellaneous-1/src/main/java/com/baeldung/algorithms/mcts/tictactoe/Board.java
diff --git a/algorithms/src/main/java/com/baeldung/algorithms/mcts/tictactoe/Position.java b/algorithms-miscellaneous-1/src/main/java/com/baeldung/algorithms/mcts/tictactoe/Position.java
similarity index 100%
rename from algorithms/src/main/java/com/baeldung/algorithms/mcts/tictactoe/Position.java
rename to algorithms-miscellaneous-1/src/main/java/com/baeldung/algorithms/mcts/tictactoe/Position.java
diff --git a/algorithms/src/main/java/com/baeldung/algorithms/mcts/tree/Node.java b/algorithms-miscellaneous-1/src/main/java/com/baeldung/algorithms/mcts/tree/Node.java
similarity index 100%
rename from algorithms/src/main/java/com/baeldung/algorithms/mcts/tree/Node.java
rename to algorithms-miscellaneous-1/src/main/java/com/baeldung/algorithms/mcts/tree/Node.java
diff --git a/algorithms/src/main/java/com/baeldung/algorithms/mcts/tree/Tree.java b/algorithms-miscellaneous-1/src/main/java/com/baeldung/algorithms/mcts/tree/Tree.java
similarity index 100%
rename from algorithms/src/main/java/com/baeldung/algorithms/mcts/tree/Tree.java
rename to algorithms-miscellaneous-1/src/main/java/com/baeldung/algorithms/mcts/tree/Tree.java
diff --git a/algorithms/src/main/java/com/baeldung/algorithms/middleelementlookup/MiddleElementLookup.java b/algorithms-miscellaneous-1/src/main/java/com/baeldung/algorithms/middleelementlookup/MiddleElementLookup.java
similarity index 100%
rename from algorithms/src/main/java/com/baeldung/algorithms/middleelementlookup/MiddleElementLookup.java
rename to algorithms-miscellaneous-1/src/main/java/com/baeldung/algorithms/middleelementlookup/MiddleElementLookup.java
diff --git a/algorithms/src/main/java/com/baeldung/algorithms/middleelementlookup/Node.java b/algorithms-miscellaneous-1/src/main/java/com/baeldung/algorithms/middleelementlookup/Node.java
similarity index 100%
rename from algorithms/src/main/java/com/baeldung/algorithms/middleelementlookup/Node.java
rename to algorithms-miscellaneous-1/src/main/java/com/baeldung/algorithms/middleelementlookup/Node.java
diff --git a/algorithms/src/main/java/com/baeldung/algorithms/minimax/GameOfBones.java b/algorithms-miscellaneous-1/src/main/java/com/baeldung/algorithms/minimax/GameOfBones.java
similarity index 100%
rename from algorithms/src/main/java/com/baeldung/algorithms/minimax/GameOfBones.java
rename to algorithms-miscellaneous-1/src/main/java/com/baeldung/algorithms/minimax/GameOfBones.java
diff --git a/algorithms/src/main/java/com/baeldung/algorithms/minimax/MiniMax.java b/algorithms-miscellaneous-1/src/main/java/com/baeldung/algorithms/minimax/MiniMax.java
similarity index 100%
rename from algorithms/src/main/java/com/baeldung/algorithms/minimax/MiniMax.java
rename to algorithms-miscellaneous-1/src/main/java/com/baeldung/algorithms/minimax/MiniMax.java
diff --git a/algorithms/src/main/java/com/baeldung/algorithms/minimax/Node.java b/algorithms-miscellaneous-1/src/main/java/com/baeldung/algorithms/minimax/Node.java
similarity index 100%
rename from algorithms/src/main/java/com/baeldung/algorithms/minimax/Node.java
rename to algorithms-miscellaneous-1/src/main/java/com/baeldung/algorithms/minimax/Node.java
diff --git a/algorithms/src/main/java/com/baeldung/algorithms/minimax/Tree.java b/algorithms-miscellaneous-1/src/main/java/com/baeldung/algorithms/minimax/Tree.java
similarity index 100%
rename from algorithms/src/main/java/com/baeldung/algorithms/minimax/Tree.java
rename to algorithms-miscellaneous-1/src/main/java/com/baeldung/algorithms/minimax/Tree.java
diff --git a/algorithms/src/main/java/com/baeldung/algorithms/multiswarm/Constants.java b/algorithms-miscellaneous-1/src/main/java/com/baeldung/algorithms/multiswarm/Constants.java
similarity index 100%
rename from algorithms/src/main/java/com/baeldung/algorithms/multiswarm/Constants.java
rename to algorithms-miscellaneous-1/src/main/java/com/baeldung/algorithms/multiswarm/Constants.java
diff --git a/algorithms/src/main/java/com/baeldung/algorithms/multiswarm/FitnessFunction.java b/algorithms-miscellaneous-1/src/main/java/com/baeldung/algorithms/multiswarm/FitnessFunction.java
similarity index 100%
rename from algorithms/src/main/java/com/baeldung/algorithms/multiswarm/FitnessFunction.java
rename to algorithms-miscellaneous-1/src/main/java/com/baeldung/algorithms/multiswarm/FitnessFunction.java
diff --git a/algorithms/src/main/java/com/baeldung/algorithms/multiswarm/Multiswarm.java b/algorithms-miscellaneous-1/src/main/java/com/baeldung/algorithms/multiswarm/Multiswarm.java
similarity index 100%
rename from algorithms/src/main/java/com/baeldung/algorithms/multiswarm/Multiswarm.java
rename to algorithms-miscellaneous-1/src/main/java/com/baeldung/algorithms/multiswarm/Multiswarm.java
diff --git a/algorithms/src/main/java/com/baeldung/algorithms/multiswarm/Particle.java b/algorithms-miscellaneous-1/src/main/java/com/baeldung/algorithms/multiswarm/Particle.java
similarity index 100%
rename from algorithms/src/main/java/com/baeldung/algorithms/multiswarm/Particle.java
rename to algorithms-miscellaneous-1/src/main/java/com/baeldung/algorithms/multiswarm/Particle.java
diff --git a/algorithms/src/main/java/com/baeldung/algorithms/multiswarm/Swarm.java b/algorithms-miscellaneous-1/src/main/java/com/baeldung/algorithms/multiswarm/Swarm.java
similarity index 100%
rename from algorithms/src/main/java/com/baeldung/algorithms/multiswarm/Swarm.java
rename to algorithms-miscellaneous-1/src/main/java/com/baeldung/algorithms/multiswarm/Swarm.java
diff --git a/algorithms/src/main/java/com/baeldung/algorithms/string/EnglishAlphabetLetters.java b/algorithms-miscellaneous-1/src/main/java/com/baeldung/algorithms/string/EnglishAlphabetLetters.java
similarity index 100%
rename from algorithms/src/main/java/com/baeldung/algorithms/string/EnglishAlphabetLetters.java
rename to algorithms-miscellaneous-1/src/main/java/com/baeldung/algorithms/string/EnglishAlphabetLetters.java
diff --git a/algorithms/src/main/java/com/baeldung/algorithms/string/search/StringSearchAlgorithms.java b/algorithms-miscellaneous-1/src/main/java/com/baeldung/algorithms/string/search/StringSearchAlgorithms.java
similarity index 100%
rename from algorithms/src/main/java/com/baeldung/algorithms/string/search/StringSearchAlgorithms.java
rename to algorithms-miscellaneous-1/src/main/java/com/baeldung/algorithms/string/search/StringSearchAlgorithms.java
diff --git a/algorithms/src/main/resources/logback.xml b/algorithms-miscellaneous-1/src/main/resources/logback.xml
similarity index 100%
rename from algorithms/src/main/resources/logback.xml
rename to algorithms-miscellaneous-1/src/main/resources/logback.xml
diff --git a/algorithms/src/main/resources/maze/maze1.txt b/algorithms-miscellaneous-1/src/main/resources/maze/maze1.txt
similarity index 92%
rename from algorithms/src/main/resources/maze/maze1.txt
rename to algorithms-miscellaneous-1/src/main/resources/maze/maze1.txt
index 0a6309d25b..8b48c325d2 100644
--- a/algorithms/src/main/resources/maze/maze1.txt
+++ b/algorithms-miscellaneous-1/src/main/resources/maze/maze1.txt
@@ -1,12 +1,12 @@
-S ########
-# #
-# ### ## #
-# # # #
-# # # # #
-# ## #####
-# # #
-# # # # #
-##### ####
-# # E
-# # # #
+S ########
+# #
+# ### ## #
+# # # #
+# # # # #
+# ## #####
+# # #
+# # # # #
+##### ####
+# # E
+# # # #
##########
\ No newline at end of file
diff --git a/algorithms/src/main/resources/maze/maze2.txt b/algorithms-miscellaneous-1/src/main/resources/maze/maze2.txt
similarity index 96%
rename from algorithms/src/main/resources/maze/maze2.txt
rename to algorithms-miscellaneous-1/src/main/resources/maze/maze2.txt
index 22e6d0382a..df5b6bc66b 100644
--- a/algorithms/src/main/resources/maze/maze2.txt
+++ b/algorithms-miscellaneous-1/src/main/resources/maze/maze2.txt
@@ -1,22 +1,22 @@
-S ##########################
-# # # #
-# # #### ############### #
-# # # # # #
-# # #### # # ###############
-# # # # # # #
-# # # #### ### ########### #
-# # # # # #
-# ################## #
-######### # # # # #
-# # #### # ####### # #
-# # ### ### # # # # #
-# # ## # ##### # #
-##### ####### # # # # #
-# # ## ## #### # #
-# ##### ####### # #
-# # ############
-####### ######### # #
-# # ######## #
-# ####### ###### ## # E
-# # # ## #
+S ##########################
+# # # #
+# # #### ############### #
+# # # # # #
+# # #### # # ###############
+# # # # # # #
+# # # #### ### ########### #
+# # # # # #
+# ################## #
+######### # # # # #
+# # #### # ####### # #
+# # ### ### # # # # #
+# # ## # ##### # #
+##### ####### # # # # #
+# # ## ## #### # #
+# ##### ####### # #
+# # ############
+####### ######### # #
+# # ######## #
+# ####### ###### ## # E
+# # # ## #
############################
\ No newline at end of file
diff --git a/algorithms/src/test/java/com/baeldung/algorithms/HillClimbingAlgorithmUnitTest.java b/algorithms-miscellaneous-1/src/test/java/com/baeldung/algorithms/HillClimbingAlgorithmUnitTest.java
similarity index 100%
rename from algorithms/src/test/java/com/baeldung/algorithms/HillClimbingAlgorithmUnitTest.java
rename to algorithms-miscellaneous-1/src/test/java/com/baeldung/algorithms/HillClimbingAlgorithmUnitTest.java
diff --git a/algorithms/src/test/java/com/baeldung/algorithms/MiddleElementLookupUnitTest.java b/algorithms-miscellaneous-1/src/test/java/com/baeldung/algorithms/MiddleElementLookupUnitTest.java
similarity index 100%
rename from algorithms/src/test/java/com/baeldung/algorithms/MiddleElementLookupUnitTest.java
rename to algorithms-miscellaneous-1/src/test/java/com/baeldung/algorithms/MiddleElementLookupUnitTest.java
diff --git a/algorithms/src/test/java/com/baeldung/algorithms/RtFiniteStateMachineLongRunningUnitTest.java b/algorithms-miscellaneous-1/src/test/java/com/baeldung/algorithms/RtFiniteStateMachineLongRunningUnitTest.java
similarity index 100%
rename from algorithms/src/test/java/com/baeldung/algorithms/RtFiniteStateMachineLongRunningUnitTest.java
rename to algorithms-miscellaneous-1/src/test/java/com/baeldung/algorithms/RtFiniteStateMachineLongRunningUnitTest.java
diff --git a/algorithms/src/test/java/com/baeldung/algorithms/StringSearchAlgorithmsUnitTest.java b/algorithms-miscellaneous-1/src/test/java/com/baeldung/algorithms/StringSearchAlgorithmsUnitTest.java
similarity index 100%
rename from algorithms/src/test/java/com/baeldung/algorithms/StringSearchAlgorithmsUnitTest.java
rename to algorithms-miscellaneous-1/src/test/java/com/baeldung/algorithms/StringSearchAlgorithmsUnitTest.java
diff --git a/algorithms/src/test/java/com/baeldung/algorithms/binarysearch/BinarySearchUnitTest.java b/algorithms-miscellaneous-1/src/test/java/com/baeldung/algorithms/binarysearch/BinarySearchUnitTest.java
similarity index 100%
rename from algorithms/src/test/java/com/baeldung/algorithms/binarysearch/BinarySearchUnitTest.java
rename to algorithms-miscellaneous-1/src/test/java/com/baeldung/algorithms/binarysearch/BinarySearchUnitTest.java
diff --git a/algorithms/src/test/java/com/baeldung/algorithms/kthlargest/FindKthLargestUnitTest.java b/algorithms-miscellaneous-1/src/test/java/com/baeldung/algorithms/kthlargest/FindKthLargestUnitTest.java
similarity index 100%
rename from algorithms/src/test/java/com/baeldung/algorithms/kthlargest/FindKthLargestUnitTest.java
rename to algorithms-miscellaneous-1/src/test/java/com/baeldung/algorithms/kthlargest/FindKthLargestUnitTest.java
diff --git a/algorithms/src/test/java/com/baeldung/algorithms/linesintersection/LinesIntersectionServiceUnitTest.java b/algorithms-miscellaneous-1/src/test/java/com/baeldung/algorithms/linesintersection/LinesIntersectionServiceUnitTest.java
similarity index 100%
rename from algorithms/src/test/java/com/baeldung/algorithms/linesintersection/LinesIntersectionServiceUnitTest.java
rename to algorithms-miscellaneous-1/src/test/java/com/baeldung/algorithms/linesintersection/LinesIntersectionServiceUnitTest.java
diff --git a/algorithms/src/test/java/com/baeldung/algorithms/mcts/MCTSUnitTest.java b/algorithms-miscellaneous-1/src/test/java/com/baeldung/algorithms/mcts/MCTSUnitTest.java
similarity index 100%
rename from algorithms/src/test/java/com/baeldung/algorithms/mcts/MCTSUnitTest.java
rename to algorithms-miscellaneous-1/src/test/java/com/baeldung/algorithms/mcts/MCTSUnitTest.java
diff --git a/algorithms/src/test/java/com/baeldung/algorithms/minimax/MinimaxUnitTest.java b/algorithms-miscellaneous-1/src/test/java/com/baeldung/algorithms/minimax/MinimaxUnitTest.java
similarity index 100%
rename from algorithms/src/test/java/com/baeldung/algorithms/minimax/MinimaxUnitTest.java
rename to algorithms-miscellaneous-1/src/test/java/com/baeldung/algorithms/minimax/MinimaxUnitTest.java
diff --git a/algorithms/src/test/java/com/baeldung/algorithms/multiswarm/LolFitnessFunction.java b/algorithms-miscellaneous-1/src/test/java/com/baeldung/algorithms/multiswarm/LolFitnessFunction.java
similarity index 100%
rename from algorithms/src/test/java/com/baeldung/algorithms/multiswarm/LolFitnessFunction.java
rename to algorithms-miscellaneous-1/src/test/java/com/baeldung/algorithms/multiswarm/LolFitnessFunction.java
diff --git a/algorithms/src/test/java/com/baeldung/algorithms/multiswarm/MultiswarmUnitTest.java b/algorithms-miscellaneous-1/src/test/java/com/baeldung/algorithms/multiswarm/MultiswarmUnitTest.java
similarity index 100%
rename from algorithms/src/test/java/com/baeldung/algorithms/multiswarm/MultiswarmUnitTest.java
rename to algorithms-miscellaneous-1/src/test/java/com/baeldung/algorithms/multiswarm/MultiswarmUnitTest.java
diff --git a/algorithms/src/test/java/com/baeldung/algorithms/string/EnglishAlphabetLettersUnitTest.java b/algorithms-miscellaneous-1/src/test/java/com/baeldung/algorithms/string/EnglishAlphabetLettersUnitTest.java
similarity index 100%
rename from algorithms/src/test/java/com/baeldung/algorithms/string/EnglishAlphabetLettersUnitTest.java
rename to algorithms-miscellaneous-1/src/test/java/com/baeldung/algorithms/string/EnglishAlphabetLettersUnitTest.java
diff --git a/algorithms/src/test/java/com/baeldung/algorithms/support/MayFailRule.java b/algorithms-miscellaneous-1/src/test/java/com/baeldung/algorithms/support/MayFailRule.java
similarity index 100%
rename from algorithms/src/test/java/com/baeldung/algorithms/support/MayFailRule.java
rename to algorithms-miscellaneous-1/src/test/java/com/baeldung/algorithms/support/MayFailRule.java
diff --git a/algorithms-miscellaneous-2/.gitignore b/algorithms-miscellaneous-2/.gitignore
new file mode 100644
index 0000000000..30b2b7442c
--- /dev/null
+++ b/algorithms-miscellaneous-2/.gitignore
@@ -0,0 +1,4 @@
+/target/
+.settings/
+.classpath
+.project
\ No newline at end of file
diff --git a/algorithms/README.md b/algorithms-miscellaneous-2/README.md
similarity index 54%
rename from algorithms/README.md
rename to algorithms-miscellaneous-2/README.md
index b9a37a7bf2..2634fd6b56 100644
--- a/algorithms/README.md
+++ b/algorithms-miscellaneous-2/README.md
@@ -2,20 +2,8 @@
- [Dijkstra Algorithm in Java](http://www.baeldung.com/java-dijkstra)
- [Introduction to Cobertura](http://www.baeldung.com/cobertura)
-- [Ant Colony Optimization](http://www.baeldung.com/java-ant-colony-optimization)
-- [Validating Input With Finite Automata in Java](http://www.baeldung.com/java-finite-automata)
-- [Introduction to Jenetics Library](http://www.baeldung.com/jenetics)
-- [Example of Hill Climbing Algorithm](http://www.baeldung.com/java-hill-climbing-algorithm)
-- [Monte Carlo Tree Search for Tic-Tac-Toe Game](http://www.baeldung.com/java-monte-carlo-tree-search)
-- [String Search Algorithms for Large Texts](http://www.baeldung.com/java-full-text-search-algorithms)
- [Test a Linked List for Cyclicity](http://www.baeldung.com/java-linked-list-cyclicity)
-- [Binary Search Algorithm in Java](http://www.baeldung.com/java-binary-search)
-- [Bubble Sort in Java](http://www.baeldung.com/java-bubble-sort)
- [Introduction to JGraphT](http://www.baeldung.com/jgrapht)
-- [Introduction to Minimax Algorithm](http://www.baeldung.com/java-minimax-algorithm)
-- [How to Calculate Levenshtein Distance in Java?](http://www.baeldung.com/java-levenshtein-distance)
-- [How to Find the Kth Largest Element in Java](http://www.baeldung.com/java-kth-largest-element)
-- [Multi-Swarm Optimization Algorithm in Java](http://www.baeldung.com/java-multi-swarm-algorithm)
- [A Maze Solver in Java](http://www.baeldung.com/java-solve-maze)
- [Create a Sudoku Solver in Java](http://www.baeldung.com/java-sudoku)
- [Displaying Money Amounts in Words](http://www.baeldung.com/java-money-into-words)
@@ -27,10 +15,6 @@
- [Check If Two Rectangles Overlap In Java](https://www.baeldung.com/java-check-if-two-rectangles-overlap)
- [Calculate the Distance Between Two Points in Java](https://www.baeldung.com/java-distance-between-two-points)
- [Find the Intersection of Two Lines in Java](https://www.baeldung.com/java-intersection-of-two-lines)
-- [Check If a String Contains All The Letters of The Alphabet](https://www.baeldung.com/java-string-contains-all-letters)
- [Round Up to the Nearest Hundred](https://www.baeldung.com/java-round-up-nearest-hundred)
-- [Merge Sort in Java](https://www.baeldung.com/java-merge-sort)
- [Calculate Percentage in Java](https://www.baeldung.com/java-calculate-percentage)
-- [Quicksort Algorithm Implementation in Java](https://www.baeldung.com/java-quicksort)
-- [Insertion Sort in Java](https://www.baeldung.com/java-insertion-sort)
- [Converting Between Byte Arrays and Hexadecimal Strings in Java](https://www.baeldung.com/java-byte-arrays-hex-strings)
diff --git a/algorithms/pom.xml b/algorithms-miscellaneous-2/pom.xml
similarity index 89%
rename from algorithms/pom.xml
rename to algorithms-miscellaneous-2/pom.xml
index db4a1c2eff..eeae544612 100644
--- a/algorithms/pom.xml
+++ b/algorithms-miscellaneous-2/pom.xml
@@ -1,96 +1,90 @@
-
- 4.0.0
- com.baeldung
- algorithms
- 0.0.1-SNAPSHOT
-
-
- com.baeldung
- parent-modules
- 1.0.0-SNAPSHOT
-
-
-
-
- org.apache.commons
- commons-math3
- ${commons-math3.version}
-
-
- commons-codec
- commons-codec
- ${commons-codec.version}
-
-
- org.projectlombok
- lombok
- ${lombok.version}
- provided
-
-
- io.jenetics
- jenetics
- ${io.jenetics.version}
-
-
- org.jgrapht
- jgrapht-core
- ${org.jgrapht.core.version}
-
-
- pl.allegro.finance
- tradukisto
- ${tradukisto.version}
-
-
- org.assertj
- assertj-core
- ${org.assertj.core.version}
- test
-
-
-
-
-
-
-
- org.codehaus.mojo
- exec-maven-plugin
- ${exec-maven-plugin.version}
-
-
-
-
-
-
-
-
- org.codehaus.mojo
- cobertura-maven-plugin
- 2.7
-
-
-
- com/baeldung/algorithms/dijkstra/*
-
-
- com/baeldung/algorithms/dijkstra/*
-
-
-
-
-
-
-
-
- 1.16.12
- 3.6.1
- 1.0.1
- 3.7.0
- 1.0.1
- 3.9.0
- 1.11
-
-
+
+ 4.0.0
+ com.baeldung
+ algorithms-miscellaneous-2
+ 0.0.1-SNAPSHOT
+
+
+ com.baeldung
+ parent-modules
+ 1.0.0-SNAPSHOT
+
+
+
+
+ org.apache.commons
+ commons-math3
+ ${commons-math3.version}
+
+
+ commons-codec
+ commons-codec
+ ${commons-codec.version}
+
+
+ org.projectlombok
+ lombok
+ ${lombok.version}
+ provided
+
+
+ org.jgrapht
+ jgrapht-core
+ ${org.jgrapht.core.version}
+
+
+ pl.allegro.finance
+ tradukisto
+ ${tradukisto.version}
+
+
+ org.assertj
+ assertj-core
+ ${org.assertj.core.version}
+ test
+
+
+
+
+
+
+
+ org.codehaus.mojo
+ exec-maven-plugin
+ ${exec-maven-plugin.version}
+
+
+
+
+
+
+
+
+ org.codehaus.mojo
+ cobertura-maven-plugin
+ 2.7
+
+
+
+ com/baeldung/algorithms/dijkstra/*
+
+
+ com/baeldung/algorithms/dijkstra/*
+
+
+
+
+
+
+
+
+ 1.16.12
+ 3.6.1
+ 1.0.1
+ 1.0.1
+ 3.9.0
+ 1.11
+
+
\ No newline at end of file
diff --git a/algorithms-miscellaneous-2/roundUpToHundred/.gitignore b/algorithms-miscellaneous-2/roundUpToHundred/.gitignore
new file mode 100644
index 0000000000..ae3c172604
--- /dev/null
+++ b/algorithms-miscellaneous-2/roundUpToHundred/.gitignore
@@ -0,0 +1 @@
+/bin/
diff --git a/algorithms-miscellaneous-2/roundUpToHundred/src/com/java/src/RoundUpToHundred.java b/algorithms-miscellaneous-2/roundUpToHundred/src/com/java/src/RoundUpToHundred.java
new file mode 100644
index 0000000000..6c02a340d3
--- /dev/null
+++ b/algorithms-miscellaneous-2/roundUpToHundred/src/com/java/src/RoundUpToHundred.java
@@ -0,0 +1,20 @@
+package com.java.src;
+
+import java.util.Scanner;
+
+public class RoundUpToHundred {
+
+ public static void main(String[] args) {
+ Scanner scanner = new Scanner(System.in);
+ double input = scanner.nextDouble();
+ scanner.close();
+
+ RoundUpToHundred.round(input);
+ }
+
+ static long round(double input) {
+ long i = (long) Math.ceil(input);
+ return ((i + 99) / 100) * 100;
+ };
+
+}
diff --git a/algorithms-miscellaneous-2/roundUpToHundred/src/com/java/src/RoundUpToHundredTest.java b/algorithms-miscellaneous-2/roundUpToHundred/src/com/java/src/RoundUpToHundredTest.java
new file mode 100644
index 0000000000..cb541ad49c
--- /dev/null
+++ b/algorithms-miscellaneous-2/roundUpToHundred/src/com/java/src/RoundUpToHundredTest.java
@@ -0,0 +1,14 @@
+package com.java.src;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+
+public class RoundUpToHundredTest {
+ @Test
+ public void givenInput_whenRound_thenRoundUpToTheNearestHundred() {
+ assertEquals("Rounded up to hundred", 100, RoundUpToHundred.round(99));
+ assertEquals("Rounded up to three hundred ", 300, RoundUpToHundred.round(200.2));
+ assertEquals("Returns same rounded value", 400, RoundUpToHundred.round(400));
+ }
+}
diff --git a/algorithms/src/main/java/com/baeldung/algorithms/conversion/HexStringConverter.java b/algorithms-miscellaneous-2/src/main/java/com/baeldung/algorithms/conversion/HexStringConverter.java
similarity index 100%
rename from algorithms/src/main/java/com/baeldung/algorithms/conversion/HexStringConverter.java
rename to algorithms-miscellaneous-2/src/main/java/com/baeldung/algorithms/conversion/HexStringConverter.java
diff --git a/algorithms/src/main/java/com/baeldung/algorithms/distancebetweenpoints/DistanceBetweenPointsService.java b/algorithms-miscellaneous-2/src/main/java/com/baeldung/algorithms/distancebetweenpoints/DistanceBetweenPointsService.java
similarity index 100%
rename from algorithms/src/main/java/com/baeldung/algorithms/distancebetweenpoints/DistanceBetweenPointsService.java
rename to algorithms-miscellaneous-2/src/main/java/com/baeldung/algorithms/distancebetweenpoints/DistanceBetweenPointsService.java
diff --git a/algorithms/src/main/java/com/baeldung/algorithms/editdistance/EditDistanceBase.java b/algorithms-miscellaneous-2/src/main/java/com/baeldung/algorithms/editdistance/EditDistanceBase.java
similarity index 95%
rename from algorithms/src/main/java/com/baeldung/algorithms/editdistance/EditDistanceBase.java
rename to algorithms-miscellaneous-2/src/main/java/com/baeldung/algorithms/editdistance/EditDistanceBase.java
index ec66621928..4df1de9994 100644
--- a/algorithms/src/main/java/com/baeldung/algorithms/editdistance/EditDistanceBase.java
+++ b/algorithms-miscellaneous-2/src/main/java/com/baeldung/algorithms/editdistance/EditDistanceBase.java
@@ -1,15 +1,15 @@
-package com.baeldung.algorithms.editdistance;
-
-import java.util.Arrays;
-
-public class EditDistanceBase {
-
- static int costOfSubstitution(char a, char b) {
- return a == b ? 0 : 1;
- }
-
- static int min(int... numbers) {
- return Arrays.stream(numbers)
- .min().orElse(Integer.MAX_VALUE);
- }
-}
+package com.baeldung.algorithms.editdistance;
+
+import java.util.Arrays;
+
+public class EditDistanceBase {
+
+ static int costOfSubstitution(char a, char b) {
+ return a == b ? 0 : 1;
+ }
+
+ static int min(int... numbers) {
+ return Arrays.stream(numbers)
+ .min().orElse(Integer.MAX_VALUE);
+ }
+}
diff --git a/algorithms/src/main/java/com/baeldung/algorithms/editdistance/EditDistanceDynamicProgramming.java b/algorithms-miscellaneous-2/src/main/java/com/baeldung/algorithms/editdistance/EditDistanceDynamicProgramming.java
similarity index 96%
rename from algorithms/src/main/java/com/baeldung/algorithms/editdistance/EditDistanceDynamicProgramming.java
rename to algorithms-miscellaneous-2/src/main/java/com/baeldung/algorithms/editdistance/EditDistanceDynamicProgramming.java
index 1f8824c4f4..10ce43bf5f 100644
--- a/algorithms/src/main/java/com/baeldung/algorithms/editdistance/EditDistanceDynamicProgramming.java
+++ b/algorithms-miscellaneous-2/src/main/java/com/baeldung/algorithms/editdistance/EditDistanceDynamicProgramming.java
@@ -1,26 +1,26 @@
-package com.baeldung.algorithms.editdistance;
-
-public class EditDistanceDynamicProgramming extends EditDistanceBase {
-
- static int calculate(String x, String y) {
- int[][] dp = new int[x.length() + 1][y.length() + 1];
-
- for (int i = 0; i <= x.length(); i++) {
- for (int j = 0; j <= y.length(); j++) {
- if (i == 0)
- dp[i][j] = j;
-
- else if (j == 0)
- dp[i][j] = i;
-
- else {
- dp[i][j] = min(dp[i - 1][j - 1]
- + costOfSubstitution(x.charAt(i - 1), y.charAt(j - 1)),
- dp[i - 1][j] + 1, dp[i][j - 1] + 1);
- }
- }
- }
-
- return dp[x.length()][y.length()];
- }
-}
+package com.baeldung.algorithms.editdistance;
+
+public class EditDistanceDynamicProgramming extends EditDistanceBase {
+
+ static int calculate(String x, String y) {
+ int[][] dp = new int[x.length() + 1][y.length() + 1];
+
+ for (int i = 0; i <= x.length(); i++) {
+ for (int j = 0; j <= y.length(); j++) {
+ if (i == 0)
+ dp[i][j] = j;
+
+ else if (j == 0)
+ dp[i][j] = i;
+
+ else {
+ dp[i][j] = min(dp[i - 1][j - 1]
+ + costOfSubstitution(x.charAt(i - 1), y.charAt(j - 1)),
+ dp[i - 1][j] + 1, dp[i][j - 1] + 1);
+ }
+ }
+ }
+
+ return dp[x.length()][y.length()];
+ }
+}
diff --git a/algorithms/src/main/java/com/baeldung/algorithms/editdistance/EditDistanceRecursive.java b/algorithms-miscellaneous-2/src/main/java/com/baeldung/algorithms/editdistance/EditDistanceRecursive.java
similarity index 96%
rename from algorithms/src/main/java/com/baeldung/algorithms/editdistance/EditDistanceRecursive.java
rename to algorithms-miscellaneous-2/src/main/java/com/baeldung/algorithms/editdistance/EditDistanceRecursive.java
index 8ed48dc554..fc907c45f8 100644
--- a/algorithms/src/main/java/com/baeldung/algorithms/editdistance/EditDistanceRecursive.java
+++ b/algorithms-miscellaneous-2/src/main/java/com/baeldung/algorithms/editdistance/EditDistanceRecursive.java
@@ -1,21 +1,21 @@
-package com.baeldung.algorithms.editdistance;
-
-public class EditDistanceRecursive extends EditDistanceBase {
-
- static int calculate(String x, String y) {
-
- if (x.isEmpty()) {
- return y.length();
- }
-
- if (y.isEmpty()) {
- return x.length();
- }
-
- int substitution = calculate(x.substring(1), y.substring(1)) + costOfSubstitution(x.charAt(0), y.charAt(0));
- int insertion = calculate(x, y.substring(1)) + 1;
- int deletion = calculate(x.substring(1), y) + 1;
-
- return min(substitution, insertion, deletion);
- }
-}
+package com.baeldung.algorithms.editdistance;
+
+public class EditDistanceRecursive extends EditDistanceBase {
+
+ static int calculate(String x, String y) {
+
+ if (x.isEmpty()) {
+ return y.length();
+ }
+
+ if (y.isEmpty()) {
+ return x.length();
+ }
+
+ int substitution = calculate(x.substring(1), y.substring(1)) + costOfSubstitution(x.charAt(0), y.charAt(0));
+ int insertion = calculate(x, y.substring(1)) + 1;
+ int deletion = calculate(x.substring(1), y) + 1;
+
+ return min(substitution, insertion, deletion);
+ }
+}
diff --git a/algorithms/src/main/java/com/baeldung/algorithms/linkedlist/CycleDetectionBruteForce.java b/algorithms-miscellaneous-2/src/main/java/com/baeldung/algorithms/linkedlist/CycleDetectionBruteForce.java
similarity index 96%
rename from algorithms/src/main/java/com/baeldung/algorithms/linkedlist/CycleDetectionBruteForce.java
rename to algorithms-miscellaneous-2/src/main/java/com/baeldung/algorithms/linkedlist/CycleDetectionBruteForce.java
index 1df425ad2e..907bd9042d 100644
--- a/algorithms/src/main/java/com/baeldung/algorithms/linkedlist/CycleDetectionBruteForce.java
+++ b/algorithms-miscellaneous-2/src/main/java/com/baeldung/algorithms/linkedlist/CycleDetectionBruteForce.java
@@ -1,38 +1,38 @@
-package com.baeldung.algorithms.linkedlist;
-
-public class CycleDetectionBruteForce {
-
- public static CycleDetectionResult detectCycle(Node head) {
- if (head == null) {
- return new CycleDetectionResult<>(false, null);
- }
-
- Node it1 = head;
- int nodesTraversedByOuter = 0;
- while (it1 != null && it1.next != null) {
- it1 = it1.next;
- nodesTraversedByOuter++;
-
- int x = nodesTraversedByOuter;
- Node it2 = head;
- int noOfTimesCurrentNodeVisited = 0;
-
- while (x > 0) {
- it2 = it2.next;
-
- if (it2 == it1) {
- noOfTimesCurrentNodeVisited++;
- }
-
- if (noOfTimesCurrentNodeVisited == 2) {
- return new CycleDetectionResult<>(true, it1);
- }
-
- x--;
- }
- }
-
- return new CycleDetectionResult<>(false, null);
- }
-
-}
+package com.baeldung.algorithms.linkedlist;
+
+public class CycleDetectionBruteForce {
+
+ public static CycleDetectionResult detectCycle(Node head) {
+ if (head == null) {
+ return new CycleDetectionResult<>(false, null);
+ }
+
+ Node it1 = head;
+ int nodesTraversedByOuter = 0;
+ while (it1 != null && it1.next != null) {
+ it1 = it1.next;
+ nodesTraversedByOuter++;
+
+ int x = nodesTraversedByOuter;
+ Node it2 = head;
+ int noOfTimesCurrentNodeVisited = 0;
+
+ while (x > 0) {
+ it2 = it2.next;
+
+ if (it2 == it1) {
+ noOfTimesCurrentNodeVisited++;
+ }
+
+ if (noOfTimesCurrentNodeVisited == 2) {
+ return new CycleDetectionResult<>(true, it1);
+ }
+
+ x--;
+ }
+ }
+
+ return new CycleDetectionResult<>(false, null);
+ }
+
+}
diff --git a/algorithms/src/main/java/com/baeldung/algorithms/linkedlist/CycleDetectionByFastAndSlowIterators.java b/algorithms-miscellaneous-2/src/main/java/com/baeldung/algorithms/linkedlist/CycleDetectionByFastAndSlowIterators.java
similarity index 96%
rename from algorithms/src/main/java/com/baeldung/algorithms/linkedlist/CycleDetectionByFastAndSlowIterators.java
rename to algorithms-miscellaneous-2/src/main/java/com/baeldung/algorithms/linkedlist/CycleDetectionByFastAndSlowIterators.java
index ab088de44a..2817f6f783 100644
--- a/algorithms/src/main/java/com/baeldung/algorithms/linkedlist/CycleDetectionByFastAndSlowIterators.java
+++ b/algorithms-miscellaneous-2/src/main/java/com/baeldung/algorithms/linkedlist/CycleDetectionByFastAndSlowIterators.java
@@ -1,25 +1,25 @@
-package com.baeldung.algorithms.linkedlist;
-
-public class CycleDetectionByFastAndSlowIterators {
-
- public static CycleDetectionResult detectCycle(Node head) {
- if (head == null) {
- return new CycleDetectionResult<>(false, null);
- }
-
- Node slow = head;
- Node fast = head;
-
- while (fast != null && fast.next != null) {
- slow = slow.next;
- fast = fast.next.next;
-
- if (slow == fast) {
- return new CycleDetectionResult<>(true, fast);
- }
- }
-
- return new CycleDetectionResult<>(false, null);
- }
-
-}
+package com.baeldung.algorithms.linkedlist;
+
+public class CycleDetectionByFastAndSlowIterators {
+
+ public static CycleDetectionResult detectCycle(Node head) {
+ if (head == null) {
+ return new CycleDetectionResult<>(false, null);
+ }
+
+ Node slow = head;
+ Node fast = head;
+
+ while (fast != null && fast.next != null) {
+ slow = slow.next;
+ fast = fast.next.next;
+
+ if (slow == fast) {
+ return new CycleDetectionResult<>(true, fast);
+ }
+ }
+
+ return new CycleDetectionResult<>(false, null);
+ }
+
+}
diff --git a/algorithms/src/main/java/com/baeldung/algorithms/linkedlist/CycleDetectionByHashing.java b/algorithms-miscellaneous-2/src/main/java/com/baeldung/algorithms/linkedlist/CycleDetectionByHashing.java
similarity index 96%
rename from algorithms/src/main/java/com/baeldung/algorithms/linkedlist/CycleDetectionByHashing.java
rename to algorithms-miscellaneous-2/src/main/java/com/baeldung/algorithms/linkedlist/CycleDetectionByHashing.java
index 90d5ecd711..fba4cad2e6 100644
--- a/algorithms/src/main/java/com/baeldung/algorithms/linkedlist/CycleDetectionByHashing.java
+++ b/algorithms-miscellaneous-2/src/main/java/com/baeldung/algorithms/linkedlist/CycleDetectionByHashing.java
@@ -1,27 +1,27 @@
-package com.baeldung.algorithms.linkedlist;
-
-import java.util.HashSet;
-import java.util.Set;
-
-public class CycleDetectionByHashing {
-
- public static CycleDetectionResult detectCycle(Node head) {
- if (head == null) {
- return new CycleDetectionResult<>(false, null);
- }
-
- Set> set = new HashSet<>();
- Node node = head;
-
- while (node != null) {
- if (set.contains(node)) {
- return new CycleDetectionResult<>(true, node);
- }
- set.add(node);
- node = node.next;
- }
-
- return new CycleDetectionResult<>(false, null);
- }
-
-}
+package com.baeldung.algorithms.linkedlist;
+
+import java.util.HashSet;
+import java.util.Set;
+
+public class CycleDetectionByHashing {
+
+ public static CycleDetectionResult detectCycle(Node head) {
+ if (head == null) {
+ return new CycleDetectionResult<>(false, null);
+ }
+
+ Set> set = new HashSet<>();
+ Node node = head;
+
+ while (node != null) {
+ if (set.contains(node)) {
+ return new CycleDetectionResult<>(true, node);
+ }
+ set.add(node);
+ node = node.next;
+ }
+
+ return new CycleDetectionResult<>(false, null);
+ }
+
+}
diff --git a/algorithms/src/main/java/com/baeldung/algorithms/linkedlist/CycleDetectionResult.java b/algorithms-miscellaneous-2/src/main/java/com/baeldung/algorithms/linkedlist/CycleDetectionResult.java
similarity index 96%
rename from algorithms/src/main/java/com/baeldung/algorithms/linkedlist/CycleDetectionResult.java
rename to algorithms-miscellaneous-2/src/main/java/com/baeldung/algorithms/linkedlist/CycleDetectionResult.java
index e7556311b3..4e258ec2ef 100644
--- a/algorithms/src/main/java/com/baeldung/algorithms/linkedlist/CycleDetectionResult.java
+++ b/algorithms-miscellaneous-2/src/main/java/com/baeldung/algorithms/linkedlist/CycleDetectionResult.java
@@ -1,12 +1,12 @@
-package com.baeldung.algorithms.linkedlist;
-
-public class CycleDetectionResult {
- boolean cycleExists;
- Node node;
-
- public CycleDetectionResult(boolean cycleExists, Node node) {
- super();
- this.cycleExists = cycleExists;
- this.node = node;
- }
-}
+package com.baeldung.algorithms.linkedlist;
+
+public class CycleDetectionResult {
+ boolean cycleExists;
+ Node node;
+
+ public CycleDetectionResult(boolean cycleExists, Node node) {
+ super();
+ this.cycleExists = cycleExists;
+ this.node = node;
+ }
+}
diff --git a/algorithms/src/main/java/com/baeldung/algorithms/linkedlist/CycleRemovalBruteForce.java b/algorithms-miscellaneous-2/src/main/java/com/baeldung/algorithms/linkedlist/CycleRemovalBruteForce.java
similarity index 96%
rename from algorithms/src/main/java/com/baeldung/algorithms/linkedlist/CycleRemovalBruteForce.java
rename to algorithms-miscellaneous-2/src/main/java/com/baeldung/algorithms/linkedlist/CycleRemovalBruteForce.java
index a2bfaee9a1..216ebcdde3 100644
--- a/algorithms/src/main/java/com/baeldung/algorithms/linkedlist/CycleRemovalBruteForce.java
+++ b/algorithms-miscellaneous-2/src/main/java/com/baeldung/algorithms/linkedlist/CycleRemovalBruteForce.java
@@ -1,56 +1,56 @@
-package com.baeldung.algorithms.linkedlist;
-
-public class CycleRemovalBruteForce {
-
- public static boolean detectAndRemoveCycle(Node head) {
- CycleDetectionResult result = CycleDetectionByFastAndSlowIterators.detectCycle(head);
-
- if (result.cycleExists) {
- removeCycle(result.node, head);
- }
-
- return result.cycleExists;
- }
-
- /**
- * @param loopNodeParam - reference to the node where Flyods cycle
- * finding algorithm ends, i.e. the fast and the slow iterators
- * meet.
- * @param head - reference to the head of the list
- */
- private static void removeCycle(Node loopNodeParam, Node head) {
- Node it = head;
-
- while (it != null) {
- if (isNodeReachableFromLoopNode(it, loopNodeParam)) {
- Node loopStart = it;
- findEndNodeAndBreakCycle(loopStart);
- break;
- }
- it = it.next;
- }
- }
-
- private static boolean isNodeReachableFromLoopNode(Node it, Node loopNodeParam) {
- Node loopNode = loopNodeParam;
-
- do {
- if (it == loopNode) {
- return true;
- }
- loopNode = loopNode.next;
- } while (loopNode.next != loopNodeParam);
-
- return false;
- }
-
- private static void findEndNodeAndBreakCycle(Node loopStartParam) {
- Node loopStart = loopStartParam;
-
- while (loopStart.next != loopStartParam) {
- loopStart = loopStart.next;
- }
-
- loopStart.next = null;
- }
-}
+package com.baeldung.algorithms.linkedlist;
+
+public class CycleRemovalBruteForce {
+
+ public static boolean detectAndRemoveCycle(Node head) {
+ CycleDetectionResult result = CycleDetectionByFastAndSlowIterators.detectCycle(head);
+
+ if (result.cycleExists) {
+ removeCycle(result.node, head);
+ }
+
+ return result.cycleExists;
+ }
+
+ /**
+ * @param loopNodeParam - reference to the node where Flyods cycle
+ * finding algorithm ends, i.e. the fast and the slow iterators
+ * meet.
+ * @param head - reference to the head of the list
+ */
+ private static void removeCycle(Node loopNodeParam, Node head) {
+ Node it = head;
+
+ while (it != null) {
+ if (isNodeReachableFromLoopNode(it, loopNodeParam)) {
+ Node loopStart = it;
+ findEndNodeAndBreakCycle(loopStart);
+ break;
+ }
+ it = it.next;
+ }
+ }
+
+ private static boolean isNodeReachableFromLoopNode(Node it, Node loopNodeParam) {
+ Node loopNode = loopNodeParam;
+
+ do {
+ if (it == loopNode) {
+ return true;
+ }
+ loopNode = loopNode.next;
+ } while (loopNode.next != loopNodeParam);
+
+ return false;
+ }
+
+ private static void findEndNodeAndBreakCycle(Node loopStartParam) {
+ Node loopStart = loopStartParam;
+
+ while (loopStart.next != loopStartParam) {
+ loopStart = loopStart.next;
+ }
+
+ loopStart.next = null;
+ }
+}
diff --git a/algorithms/src/main/java/com/baeldung/algorithms/linkedlist/CycleRemovalByCountingLoopNodes.java b/algorithms-miscellaneous-2/src/main/java/com/baeldung/algorithms/linkedlist/CycleRemovalByCountingLoopNodes.java
similarity index 96%
rename from algorithms/src/main/java/com/baeldung/algorithms/linkedlist/CycleRemovalByCountingLoopNodes.java
rename to algorithms-miscellaneous-2/src/main/java/com/baeldung/algorithms/linkedlist/CycleRemovalByCountingLoopNodes.java
index d8db37fc4c..f961feb97d 100644
--- a/algorithms/src/main/java/com/baeldung/algorithms/linkedlist/CycleRemovalByCountingLoopNodes.java
+++ b/algorithms-miscellaneous-2/src/main/java/com/baeldung/algorithms/linkedlist/CycleRemovalByCountingLoopNodes.java
@@ -1,44 +1,44 @@
-package com.baeldung.algorithms.linkedlist;
-
-public class CycleRemovalByCountingLoopNodes {
-
- public static boolean detectAndRemoveCycle(Node head) {
- CycleDetectionResult result = CycleDetectionByFastAndSlowIterators.detectCycle(head);
-
- if (result.cycleExists) {
- removeCycle(result.node, head);
- }
-
- return result.cycleExists;
- }
-
- private static void removeCycle(Node loopNodeParam, Node head) {
- int cycleLength = calculateCycleLength(loopNodeParam);
- Node cycleLengthAdvancedIterator = head;
- Node it = head;
-
- for (int i = 0; i < cycleLength; i++) {
- cycleLengthAdvancedIterator = cycleLengthAdvancedIterator.next;
- }
-
- while (it.next != cycleLengthAdvancedIterator.next) {
- it = it.next;
- cycleLengthAdvancedIterator = cycleLengthAdvancedIterator.next;
- }
-
- cycleLengthAdvancedIterator.next = null;
- }
-
- private static int calculateCycleLength(Node loopNodeParam) {
- Node loopNode = loopNodeParam;
- int length = 1;
-
- while (loopNode.next != loopNodeParam) {
- length++;
- loopNode = loopNode.next;
- }
-
- return length;
- }
-
-}
+package com.baeldung.algorithms.linkedlist;
+
+public class CycleRemovalByCountingLoopNodes {
+
+ public static boolean detectAndRemoveCycle(Node head) {
+ CycleDetectionResult result = CycleDetectionByFastAndSlowIterators.detectCycle(head);
+
+ if (result.cycleExists) {
+ removeCycle(result.node, head);
+ }
+
+ return result.cycleExists;
+ }
+
+ private static void removeCycle(Node loopNodeParam, Node head) {
+ int cycleLength = calculateCycleLength(loopNodeParam);
+ Node cycleLengthAdvancedIterator = head;
+ Node it = head;
+
+ for (int i = 0; i < cycleLength; i++) {
+ cycleLengthAdvancedIterator = cycleLengthAdvancedIterator.next;
+ }
+
+ while (it.next != cycleLengthAdvancedIterator.next) {
+ it = it.next;
+ cycleLengthAdvancedIterator = cycleLengthAdvancedIterator.next;
+ }
+
+ cycleLengthAdvancedIterator.next = null;
+ }
+
+ private static int calculateCycleLength(Node loopNodeParam) {
+ Node loopNode = loopNodeParam;
+ int length = 1;
+
+ while (loopNode.next != loopNodeParam) {
+ length++;
+ loopNode = loopNode.next;
+ }
+
+ return length;
+ }
+
+}
diff --git a/algorithms/src/main/java/com/baeldung/algorithms/linkedlist/CycleRemovalWithoutCountingLoopNodes.java b/algorithms-miscellaneous-2/src/main/java/com/baeldung/algorithms/linkedlist/CycleRemovalWithoutCountingLoopNodes.java
similarity index 96%
rename from algorithms/src/main/java/com/baeldung/algorithms/linkedlist/CycleRemovalWithoutCountingLoopNodes.java
rename to algorithms-miscellaneous-2/src/main/java/com/baeldung/algorithms/linkedlist/CycleRemovalWithoutCountingLoopNodes.java
index b979f7f677..1e41c832db 100644
--- a/algorithms/src/main/java/com/baeldung/algorithms/linkedlist/CycleRemovalWithoutCountingLoopNodes.java
+++ b/algorithms-miscellaneous-2/src/main/java/com/baeldung/algorithms/linkedlist/CycleRemovalWithoutCountingLoopNodes.java
@@ -1,27 +1,27 @@
-package com.baeldung.algorithms.linkedlist;
-
-public class CycleRemovalWithoutCountingLoopNodes {
-
- public static boolean detectAndRemoveCycle(Node head) {
- CycleDetectionResult result = CycleDetectionByFastAndSlowIterators.detectCycle(head);
-
- if (result.cycleExists) {
- removeCycle(result.node, head);
- }
-
- return result.cycleExists;
- }
-
- private static void removeCycle(Node meetingPointParam, Node head) {
- Node loopNode = meetingPointParam;
- Node it = head;
-
- while (loopNode.next != it.next) {
- it = it.next;
- loopNode = loopNode.next;
- }
-
- loopNode.next = null;
- }
-
-}
+package com.baeldung.algorithms.linkedlist;
+
+public class CycleRemovalWithoutCountingLoopNodes {
+
+ public static boolean detectAndRemoveCycle(Node head) {
+ CycleDetectionResult result = CycleDetectionByFastAndSlowIterators.detectCycle(head);
+
+ if (result.cycleExists) {
+ removeCycle(result.node, head);
+ }
+
+ return result.cycleExists;
+ }
+
+ private static void removeCycle(Node meetingPointParam, Node head) {
+ Node loopNode = meetingPointParam;
+ Node it = head;
+
+ while (loopNode.next != it.next) {
+ it = it.next;
+ loopNode = loopNode.next;
+ }
+
+ loopNode.next = null;
+ }
+
+}
diff --git a/algorithms/src/main/java/com/baeldung/algorithms/linkedlist/Node.java b/algorithms-miscellaneous-2/src/main/java/com/baeldung/algorithms/linkedlist/Node.java
similarity index 95%
rename from algorithms/src/main/java/com/baeldung/algorithms/linkedlist/Node.java
rename to algorithms-miscellaneous-2/src/main/java/com/baeldung/algorithms/linkedlist/Node.java
index 4add22c77d..9573bcd981 100644
--- a/algorithms/src/main/java/com/baeldung/algorithms/linkedlist/Node.java
+++ b/algorithms-miscellaneous-2/src/main/java/com/baeldung/algorithms/linkedlist/Node.java
@@ -1,38 +1,38 @@
-package com.baeldung.algorithms.linkedlist;
-
-public class Node {
- T data;
- Node next;
-
- public static Node createNewNode(T data, Node next) {
- Node node = new Node();
- node.data = data;
- node.next = next;
- return node;
- }
-
- public static void traverseList(Node root) {
- if (root == null) {
- return;
- }
-
- Node node = root;
- while (node != null) {
- System.out.println(node.data);
- node = node.next;
- }
- }
-
- public static Node getTail(Node root) {
- if (root == null) {
- return null;
- }
-
- Node node = root;
- while (node.next != null) {
- node = node.next;
- }
- return node;
- }
-
+package com.baeldung.algorithms.linkedlist;
+
+public class Node {
+ T data;
+ Node next;
+
+ public static Node createNewNode(T data, Node next) {
+ Node node = new Node();
+ node.data = data;
+ node.next = next;
+ return node;
+ }
+
+ public static void traverseList(Node root) {
+ if (root == null) {
+ return;
+ }
+
+ Node node = root;
+ while (node != null) {
+ System.out.println(node.data);
+ node = node.next;
+ }
+ }
+
+ public static Node getTail(Node root) {
+ if (root == null) {
+ return null;
+ }
+
+ Node node = root;
+ while (node.next != null) {
+ node = node.next;
+ }
+ return node;
+ }
+
}
\ No newline at end of file
diff --git a/algorithms/src/main/java/com/baeldung/algorithms/maze/solver/BFSMazeSolver.java b/algorithms-miscellaneous-2/src/main/java/com/baeldung/algorithms/maze/solver/BFSMazeSolver.java
similarity index 96%
rename from algorithms/src/main/java/com/baeldung/algorithms/maze/solver/BFSMazeSolver.java
rename to algorithms-miscellaneous-2/src/main/java/com/baeldung/algorithms/maze/solver/BFSMazeSolver.java
index 08972251b8..0e3101925c 100644
--- a/algorithms/src/main/java/com/baeldung/algorithms/maze/solver/BFSMazeSolver.java
+++ b/algorithms-miscellaneous-2/src/main/java/com/baeldung/algorithms/maze/solver/BFSMazeSolver.java
@@ -1,52 +1,52 @@
-package com.baeldung.algorithms.maze.solver;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.LinkedList;
-import java.util.List;
-
-public class BFSMazeSolver {
- private static final int[][] DIRECTIONS = { { 0, 1 }, { 1, 0 }, { 0, -1 }, { -1, 0 } };
-
- public List solve(Maze maze) {
- LinkedList nextToVisit = new LinkedList<>();
- Coordinate start = maze.getEntry();
- nextToVisit.add(start);
-
- while (!nextToVisit.isEmpty()) {
- Coordinate cur = nextToVisit.remove();
-
- if (!maze.isValidLocation(cur.getX(), cur.getY()) || maze.isExplored(cur.getX(), cur.getY())) {
- continue;
- }
-
- if (maze.isWall(cur.getX(), cur.getY())) {
- maze.setVisited(cur.getX(), cur.getY(), true);
- continue;
- }
-
- if (maze.isExit(cur.getX(), cur.getY())) {
- return backtrackPath(cur);
- }
-
- for (int[] direction : DIRECTIONS) {
- Coordinate coordinate = new Coordinate(cur.getX() + direction[0], cur.getY() + direction[1], cur);
- nextToVisit.add(coordinate);
- maze.setVisited(cur.getX(), cur.getY(), true);
- }
- }
- return Collections.emptyList();
- }
-
- private List backtrackPath(Coordinate cur) {
- List path = new ArrayList<>();
- Coordinate iter = cur;
-
- while (iter != null) {
- path.add(iter);
- iter = iter.parent;
- }
-
- return path;
- }
-}
+package com.baeldung.algorithms.maze.solver;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.List;
+
+public class BFSMazeSolver {
+ private static final int[][] DIRECTIONS = { { 0, 1 }, { 1, 0 }, { 0, -1 }, { -1, 0 } };
+
+ public List solve(Maze maze) {
+ LinkedList nextToVisit = new LinkedList<>();
+ Coordinate start = maze.getEntry();
+ nextToVisit.add(start);
+
+ while (!nextToVisit.isEmpty()) {
+ Coordinate cur = nextToVisit.remove();
+
+ if (!maze.isValidLocation(cur.getX(), cur.getY()) || maze.isExplored(cur.getX(), cur.getY())) {
+ continue;
+ }
+
+ if (maze.isWall(cur.getX(), cur.getY())) {
+ maze.setVisited(cur.getX(), cur.getY(), true);
+ continue;
+ }
+
+ if (maze.isExit(cur.getX(), cur.getY())) {
+ return backtrackPath(cur);
+ }
+
+ for (int[] direction : DIRECTIONS) {
+ Coordinate coordinate = new Coordinate(cur.getX() + direction[0], cur.getY() + direction[1], cur);
+ nextToVisit.add(coordinate);
+ maze.setVisited(cur.getX(), cur.getY(), true);
+ }
+ }
+ return Collections.emptyList();
+ }
+
+ private List backtrackPath(Coordinate cur) {
+ List path = new ArrayList<>();
+ Coordinate iter = cur;
+
+ while (iter != null) {
+ path.add(iter);
+ iter = iter.parent;
+ }
+
+ return path;
+ }
+}
diff --git a/algorithms/src/main/java/com/baeldung/algorithms/maze/solver/Coordinate.java b/algorithms-miscellaneous-2/src/main/java/com/baeldung/algorithms/maze/solver/Coordinate.java
similarity index 94%
rename from algorithms/src/main/java/com/baeldung/algorithms/maze/solver/Coordinate.java
rename to algorithms-miscellaneous-2/src/main/java/com/baeldung/algorithms/maze/solver/Coordinate.java
index 09b2ced5e6..8202c89076 100644
--- a/algorithms/src/main/java/com/baeldung/algorithms/maze/solver/Coordinate.java
+++ b/algorithms-miscellaneous-2/src/main/java/com/baeldung/algorithms/maze/solver/Coordinate.java
@@ -1,31 +1,31 @@
-package com.baeldung.algorithms.maze.solver;
-
-public class Coordinate {
- int x;
- int y;
- Coordinate parent;
-
- public Coordinate(int x, int y) {
- this.x = x;
- this.y = y;
- this.parent = null;
- }
-
- public Coordinate(int x, int y, Coordinate parent) {
- this.x = x;
- this.y = y;
- this.parent = parent;
- }
-
- int getX() {
- return x;
- }
-
- int getY() {
- return y;
- }
-
- Coordinate getParent() {
- return parent;
- }
-}
+package com.baeldung.algorithms.maze.solver;
+
+public class Coordinate {
+ int x;
+ int y;
+ Coordinate parent;
+
+ public Coordinate(int x, int y) {
+ this.x = x;
+ this.y = y;
+ this.parent = null;
+ }
+
+ public Coordinate(int x, int y, Coordinate parent) {
+ this.x = x;
+ this.y = y;
+ this.parent = parent;
+ }
+
+ int getX() {
+ return x;
+ }
+
+ int getY() {
+ return y;
+ }
+
+ Coordinate getParent() {
+ return parent;
+ }
+}
diff --git a/algorithms/src/main/java/com/baeldung/algorithms/maze/solver/DFSMazeSolver.java b/algorithms-miscellaneous-2/src/main/java/com/baeldung/algorithms/maze/solver/DFSMazeSolver.java
similarity index 96%
rename from algorithms/src/main/java/com/baeldung/algorithms/maze/solver/DFSMazeSolver.java
rename to algorithms-miscellaneous-2/src/main/java/com/baeldung/algorithms/maze/solver/DFSMazeSolver.java
index f9640066b9..ee821631db 100644
--- a/algorithms/src/main/java/com/baeldung/algorithms/maze/solver/DFSMazeSolver.java
+++ b/algorithms-miscellaneous-2/src/main/java/com/baeldung/algorithms/maze/solver/DFSMazeSolver.java
@@ -1,48 +1,48 @@
-package com.baeldung.algorithms.maze.solver;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-public class DFSMazeSolver {
- private static final int[][] DIRECTIONS = { { 0, 1 }, { 1, 0 }, { 0, -1 }, { -1, 0 } };
-
- public List solve(Maze maze) {
- List path = new ArrayList<>();
- if (explore(maze, maze.getEntry()
- .getX(),
- maze.getEntry()
- .getY(),
- path)) {
- return path;
- }
- return Collections.emptyList();
- }
-
- private boolean explore(Maze maze, int row, int col, List path) {
- if (!maze.isValidLocation(row, col) || maze.isWall(row, col) || maze.isExplored(row, col)) {
- return false;
- }
-
- path.add(new Coordinate(row, col));
- maze.setVisited(row, col, true);
-
- if (maze.isExit(row, col)) {
- return true;
- }
-
- for (int[] direction : DIRECTIONS) {
- Coordinate coordinate = getNextCoordinate(row, col, direction[0], direction[1]);
- if (explore(maze, coordinate.getX(), coordinate.getY(), path)) {
- return true;
- }
- }
-
- path.remove(path.size() - 1);
- return false;
- }
-
- private Coordinate getNextCoordinate(int row, int col, int i, int j) {
- return new Coordinate(row + i, col + j);
- }
-}
+package com.baeldung.algorithms.maze.solver;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+public class DFSMazeSolver {
+ private static final int[][] DIRECTIONS = { { 0, 1 }, { 1, 0 }, { 0, -1 }, { -1, 0 } };
+
+ public List solve(Maze maze) {
+ List path = new ArrayList<>();
+ if (explore(maze, maze.getEntry()
+ .getX(),
+ maze.getEntry()
+ .getY(),
+ path)) {
+ return path;
+ }
+ return Collections.emptyList();
+ }
+
+ private boolean explore(Maze maze, int row, int col, List path) {
+ if (!maze.isValidLocation(row, col) || maze.isWall(row, col) || maze.isExplored(row, col)) {
+ return false;
+ }
+
+ path.add(new Coordinate(row, col));
+ maze.setVisited(row, col, true);
+
+ if (maze.isExit(row, col)) {
+ return true;
+ }
+
+ for (int[] direction : DIRECTIONS) {
+ Coordinate coordinate = getNextCoordinate(row, col, direction[0], direction[1]);
+ if (explore(maze, coordinate.getX(), coordinate.getY(), path)) {
+ return true;
+ }
+ }
+
+ path.remove(path.size() - 1);
+ return false;
+ }
+
+ private Coordinate getNextCoordinate(int row, int col, int i, int j) {
+ return new Coordinate(row + i, col + j);
+ }
+}
diff --git a/algorithms/src/main/java/com/baeldung/algorithms/maze/solver/Maze.java b/algorithms-miscellaneous-2/src/main/java/com/baeldung/algorithms/maze/solver/Maze.java
similarity index 96%
rename from algorithms/src/main/java/com/baeldung/algorithms/maze/solver/Maze.java
rename to algorithms-miscellaneous-2/src/main/java/com/baeldung/algorithms/maze/solver/Maze.java
index 8aaa44d9b1..d0a0ed65d9 100644
--- a/algorithms/src/main/java/com/baeldung/algorithms/maze/solver/Maze.java
+++ b/algorithms-miscellaneous-2/src/main/java/com/baeldung/algorithms/maze/solver/Maze.java
@@ -1,141 +1,141 @@
-package com.baeldung.algorithms.maze.solver;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Scanner;
-
-public class Maze {
- private static final int ROAD = 0;
- private static final int WALL = 1;
- private static final int START = 2;
- private static final int EXIT = 3;
- private static final int PATH = 4;
-
- private int[][] maze;
- private boolean[][] visited;
- private Coordinate start;
- private Coordinate end;
-
- public Maze(File maze) throws FileNotFoundException {
- String fileText = "";
- try (Scanner input = new Scanner(maze)) {
- while (input.hasNextLine()) {
- fileText += input.nextLine() + "\n";
- }
- }
- initializeMaze(fileText);
- }
-
- private void initializeMaze(String text) {
- if (text == null || (text = text.trim()).length() == 0) {
- throw new IllegalArgumentException("empty lines data");
- }
-
- String[] lines = text.split("[\r]?\n");
- maze = new int[lines.length][lines[0].length()];
- visited = new boolean[lines.length][lines[0].length()];
-
- for (int row = 0; row < getHeight(); row++) {
- if (lines[row].length() != getWidth()) {
- throw new IllegalArgumentException("line " + (row + 1) + " wrong length (was " + lines[row].length() + " but should be " + getWidth() + ")");
- }
-
- for (int col = 0; col < getWidth(); col++) {
- if (lines[row].charAt(col) == '#')
- maze[row][col] = WALL;
- else if (lines[row].charAt(col) == 'S') {
- maze[row][col] = START;
- start = new Coordinate(row, col);
- } else if (lines[row].charAt(col) == 'E') {
- maze[row][col] = EXIT;
- end = new Coordinate(row, col);
- } else
- maze[row][col] = ROAD;
- }
- }
- }
-
- public int getHeight() {
- return maze.length;
- }
-
- public int getWidth() {
- return maze[0].length;
- }
-
- public Coordinate getEntry() {
- return start;
- }
-
- public Coordinate getExit() {
- return end;
- }
-
- public boolean isExit(int x, int y) {
- return x == end.getX() && y == end.getY();
- }
-
- public boolean isStart(int x, int y) {
- return x == start.getX() && y == start.getY();
- }
-
- public boolean isExplored(int row, int col) {
- return visited[row][col];
- }
-
- public boolean isWall(int row, int col) {
- return maze[row][col] == WALL;
- }
-
- public void setVisited(int row, int col, boolean value) {
- visited[row][col] = value;
- }
-
- public boolean isValidLocation(int row, int col) {
- if (row < 0 || row >= getHeight() || col < 0 || col >= getWidth()) {
- return false;
- }
- return true;
- }
-
- public void printPath(List path) {
- int[][] tempMaze = Arrays.stream(maze)
- .map(int[]::clone)
- .toArray(int[][]::new);
- for (Coordinate coordinate : path) {
- if (isStart(coordinate.getX(), coordinate.getY()) || isExit(coordinate.getX(), coordinate.getY())) {
- continue;
- }
- tempMaze[coordinate.getX()][coordinate.getY()] = PATH;
- }
- System.out.println(toString(tempMaze));
- }
-
- public String toString(int[][] maze) {
- StringBuilder result = new StringBuilder(getWidth() * (getHeight() + 1));
- for (int row = 0; row < getHeight(); row++) {
- for (int col = 0; col < getWidth(); col++) {
- if (maze[row][col] == ROAD) {
- result.append(' ');
- } else if (maze[row][col] == WALL) {
- result.append('#');
- } else if (maze[row][col] == START) {
- result.append('S');
- } else if (maze[row][col] == EXIT) {
- result.append('E');
- } else {
- result.append('.');
- }
- }
- result.append('\n');
- }
- return result.toString();
- }
-
- public void reset() {
- for (int i = 0; i < visited.length; i++)
- Arrays.fill(visited[i], false);
- }
-}
+package com.baeldung.algorithms.maze.solver;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Scanner;
+
+public class Maze {
+ private static final int ROAD = 0;
+ private static final int WALL = 1;
+ private static final int START = 2;
+ private static final int EXIT = 3;
+ private static final int PATH = 4;
+
+ private int[][] maze;
+ private boolean[][] visited;
+ private Coordinate start;
+ private Coordinate end;
+
+ public Maze(File maze) throws FileNotFoundException {
+ String fileText = "";
+ try (Scanner input = new Scanner(maze)) {
+ while (input.hasNextLine()) {
+ fileText += input.nextLine() + "\n";
+ }
+ }
+ initializeMaze(fileText);
+ }
+
+ private void initializeMaze(String text) {
+ if (text == null || (text = text.trim()).length() == 0) {
+ throw new IllegalArgumentException("empty lines data");
+ }
+
+ String[] lines = text.split("[\r]?\n");
+ maze = new int[lines.length][lines[0].length()];
+ visited = new boolean[lines.length][lines[0].length()];
+
+ for (int row = 0; row < getHeight(); row++) {
+ if (lines[row].length() != getWidth()) {
+ throw new IllegalArgumentException("line " + (row + 1) + " wrong length (was " + lines[row].length() + " but should be " + getWidth() + ")");
+ }
+
+ for (int col = 0; col < getWidth(); col++) {
+ if (lines[row].charAt(col) == '#')
+ maze[row][col] = WALL;
+ else if (lines[row].charAt(col) == 'S') {
+ maze[row][col] = START;
+ start = new Coordinate(row, col);
+ } else if (lines[row].charAt(col) == 'E') {
+ maze[row][col] = EXIT;
+ end = new Coordinate(row, col);
+ } else
+ maze[row][col] = ROAD;
+ }
+ }
+ }
+
+ public int getHeight() {
+ return maze.length;
+ }
+
+ public int getWidth() {
+ return maze[0].length;
+ }
+
+ public Coordinate getEntry() {
+ return start;
+ }
+
+ public Coordinate getExit() {
+ return end;
+ }
+
+ public boolean isExit(int x, int y) {
+ return x == end.getX() && y == end.getY();
+ }
+
+ public boolean isStart(int x, int y) {
+ return x == start.getX() && y == start.getY();
+ }
+
+ public boolean isExplored(int row, int col) {
+ return visited[row][col];
+ }
+
+ public boolean isWall(int row, int col) {
+ return maze[row][col] == WALL;
+ }
+
+ public void setVisited(int row, int col, boolean value) {
+ visited[row][col] = value;
+ }
+
+ public boolean isValidLocation(int row, int col) {
+ if (row < 0 || row >= getHeight() || col < 0 || col >= getWidth()) {
+ return false;
+ }
+ return true;
+ }
+
+ public void printPath(List path) {
+ int[][] tempMaze = Arrays.stream(maze)
+ .map(int[]::clone)
+ .toArray(int[][]::new);
+ for (Coordinate coordinate : path) {
+ if (isStart(coordinate.getX(), coordinate.getY()) || isExit(coordinate.getX(), coordinate.getY())) {
+ continue;
+ }
+ tempMaze[coordinate.getX()][coordinate.getY()] = PATH;
+ }
+ System.out.println(toString(tempMaze));
+ }
+
+ public String toString(int[][] maze) {
+ StringBuilder result = new StringBuilder(getWidth() * (getHeight() + 1));
+ for (int row = 0; row < getHeight(); row++) {
+ for (int col = 0; col < getWidth(); col++) {
+ if (maze[row][col] == ROAD) {
+ result.append(' ');
+ } else if (maze[row][col] == WALL) {
+ result.append('#');
+ } else if (maze[row][col] == START) {
+ result.append('S');
+ } else if (maze[row][col] == EXIT) {
+ result.append('E');
+ } else {
+ result.append('.');
+ }
+ }
+ result.append('\n');
+ }
+ return result.toString();
+ }
+
+ public void reset() {
+ for (int i = 0; i < visited.length; i++)
+ Arrays.fill(visited[i], false);
+ }
+}
diff --git a/algorithms/src/main/java/com/baeldung/algorithms/maze/solver/MazeDriver.java b/algorithms-miscellaneous-2/src/main/java/com/baeldung/algorithms/maze/solver/MazeDriver.java
similarity index 96%
rename from algorithms/src/main/java/com/baeldung/algorithms/maze/solver/MazeDriver.java
rename to algorithms-miscellaneous-2/src/main/java/com/baeldung/algorithms/maze/solver/MazeDriver.java
index 60263deba3..a47c3c8581 100644
--- a/algorithms/src/main/java/com/baeldung/algorithms/maze/solver/MazeDriver.java
+++ b/algorithms-miscellaneous-2/src/main/java/com/baeldung/algorithms/maze/solver/MazeDriver.java
@@ -1,34 +1,34 @@
-package com.baeldung.algorithms.maze.solver;
-
-import java.io.File;
-import java.util.List;
-
-public class MazeDriver {
- public static void main(String[] args) throws Exception {
- File maze1 = new File("src/main/resources/maze/maze1.txt");
- File maze2 = new File("src/main/resources/maze/maze2.txt");
-
- execute(maze1);
- execute(maze2);
- }
-
- private static void execute(File file) throws Exception {
- Maze maze = new Maze(file);
- dfs(maze);
- bfs(maze);
- }
-
- private static void bfs(Maze maze) {
- BFSMazeSolver bfs = new BFSMazeSolver();
- List path = bfs.solve(maze);
- maze.printPath(path);
- maze.reset();
- }
-
- private static void dfs(Maze maze) {
- DFSMazeSolver dfs = new DFSMazeSolver();
- List path = dfs.solve(maze);
- maze.printPath(path);
- maze.reset();
- }
-}
+package com.baeldung.algorithms.maze.solver;
+
+import java.io.File;
+import java.util.List;
+
+public class MazeDriver {
+ public static void main(String[] args) throws Exception {
+ File maze1 = new File("src/main/resources/maze/maze1.txt");
+ File maze2 = new File("src/main/resources/maze/maze2.txt");
+
+ execute(maze1);
+ execute(maze2);
+ }
+
+ private static void execute(File file) throws Exception {
+ Maze maze = new Maze(file);
+ dfs(maze);
+ bfs(maze);
+ }
+
+ private static void bfs(Maze maze) {
+ BFSMazeSolver bfs = new BFSMazeSolver();
+ List path = bfs.solve(maze);
+ maze.printPath(path);
+ maze.reset();
+ }
+
+ private static void dfs(Maze maze) {
+ DFSMazeSolver dfs = new DFSMazeSolver();
+ List path = dfs.solve(maze);
+ maze.printPath(path);
+ maze.reset();
+ }
+}
diff --git a/algorithms/src/main/java/com/baeldung/algorithms/mercator/EllipticalMercator.java b/algorithms-miscellaneous-2/src/main/java/com/baeldung/algorithms/mercator/EllipticalMercator.java
similarity index 100%
rename from algorithms/src/main/java/com/baeldung/algorithms/mercator/EllipticalMercator.java
rename to algorithms-miscellaneous-2/src/main/java/com/baeldung/algorithms/mercator/EllipticalMercator.java
diff --git a/algorithms/src/main/java/com/baeldung/algorithms/mercator/Mercator.java b/algorithms-miscellaneous-2/src/main/java/com/baeldung/algorithms/mercator/Mercator.java
similarity index 100%
rename from algorithms/src/main/java/com/baeldung/algorithms/mercator/Mercator.java
rename to algorithms-miscellaneous-2/src/main/java/com/baeldung/algorithms/mercator/Mercator.java
diff --git a/algorithms/src/main/java/com/baeldung/algorithms/mercator/SphericalMercator.java b/algorithms-miscellaneous-2/src/main/java/com/baeldung/algorithms/mercator/SphericalMercator.java
similarity index 100%
rename from algorithms/src/main/java/com/baeldung/algorithms/mercator/SphericalMercator.java
rename to algorithms-miscellaneous-2/src/main/java/com/baeldung/algorithms/mercator/SphericalMercator.java
diff --git a/algorithms/src/main/java/com/baeldung/algorithms/numberwordconverter/NumberWordConverter.java b/algorithms-miscellaneous-2/src/main/java/com/baeldung/algorithms/numberwordconverter/NumberWordConverter.java
similarity index 100%
rename from algorithms/src/main/java/com/baeldung/algorithms/numberwordconverter/NumberWordConverter.java
rename to algorithms-miscellaneous-2/src/main/java/com/baeldung/algorithms/numberwordconverter/NumberWordConverter.java
diff --git a/algorithms/src/main/java/com/baeldung/algorithms/rectanglesoverlap/Point.java b/algorithms-miscellaneous-2/src/main/java/com/baeldung/algorithms/rectanglesoverlap/Point.java
similarity index 100%
rename from algorithms/src/main/java/com/baeldung/algorithms/rectanglesoverlap/Point.java
rename to algorithms-miscellaneous-2/src/main/java/com/baeldung/algorithms/rectanglesoverlap/Point.java
diff --git a/algorithms/src/main/java/com/baeldung/algorithms/rectanglesoverlap/Rectangle.java b/algorithms-miscellaneous-2/src/main/java/com/baeldung/algorithms/rectanglesoverlap/Rectangle.java
similarity index 100%
rename from algorithms/src/main/java/com/baeldung/algorithms/rectanglesoverlap/Rectangle.java
rename to algorithms-miscellaneous-2/src/main/java/com/baeldung/algorithms/rectanglesoverlap/Rectangle.java
diff --git a/algorithms/src/main/java/com/baeldung/algorithms/romannumerals/RomanArabicConverter.java b/algorithms-miscellaneous-2/src/main/java/com/baeldung/algorithms/romannumerals/RomanArabicConverter.java
similarity index 96%
rename from algorithms/src/main/java/com/baeldung/algorithms/romannumerals/RomanArabicConverter.java
rename to algorithms-miscellaneous-2/src/main/java/com/baeldung/algorithms/romannumerals/RomanArabicConverter.java
index ab0922ecf4..acd275e609 100644
--- a/algorithms/src/main/java/com/baeldung/algorithms/romannumerals/RomanArabicConverter.java
+++ b/algorithms-miscellaneous-2/src/main/java/com/baeldung/algorithms/romannumerals/RomanArabicConverter.java
@@ -1,52 +1,52 @@
-package com.baeldung.algorithms.romannumerals;
-
-import java.util.List;
-
-class RomanArabicConverter {
-
- public static int romanToArabic(String input) {
- String romanNumeral = input.toUpperCase();
- int result = 0;
-
- List romanNumerals = RomanNumeral.getReverseSortedValues();
-
- int i = 0;
-
- while ((romanNumeral.length() > 0) && (i < romanNumerals.size())) {
- RomanNumeral symbol = romanNumerals.get(i);
- if (romanNumeral.startsWith(symbol.name())) {
- result += symbol.getValue();
- romanNumeral = romanNumeral.substring(symbol.name().length());
- } else {
- i++;
- }
- }
- if (romanNumeral.length() > 0) {
- throw new IllegalArgumentException(input + " cannot be converted to a Roman Numeral");
- }
-
- return result;
- }
-
- public static String arabicToRoman(int number) {
- if ((number <= 0) || (number > 4000)) {
- throw new IllegalArgumentException(number + " is not in range (0,4000]");
- }
-
- List romanNumerals = RomanNumeral.getReverseSortedValues();
-
- int i = 0;
- StringBuilder sb = new StringBuilder();
-
- while (number > 0 && i < romanNumerals.size()) {
- RomanNumeral currentSymbol = romanNumerals.get(i);
- if (currentSymbol.getValue() <= number) {
- sb.append(currentSymbol.name());
- number -= currentSymbol.getValue();
- } else {
- i++;
- }
- }
- return sb.toString();
- }
-}
+package com.baeldung.algorithms.romannumerals;
+
+import java.util.List;
+
+class RomanArabicConverter {
+
+ public static int romanToArabic(String input) {
+ String romanNumeral = input.toUpperCase();
+ int result = 0;
+
+ List romanNumerals = RomanNumeral.getReverseSortedValues();
+
+ int i = 0;
+
+ while ((romanNumeral.length() > 0) && (i < romanNumerals.size())) {
+ RomanNumeral symbol = romanNumerals.get(i);
+ if (romanNumeral.startsWith(symbol.name())) {
+ result += symbol.getValue();
+ romanNumeral = romanNumeral.substring(symbol.name().length());
+ } else {
+ i++;
+ }
+ }
+ if (romanNumeral.length() > 0) {
+ throw new IllegalArgumentException(input + " cannot be converted to a Roman Numeral");
+ }
+
+ return result;
+ }
+
+ public static String arabicToRoman(int number) {
+ if ((number <= 0) || (number > 4000)) {
+ throw new IllegalArgumentException(number + " is not in range (0,4000]");
+ }
+
+ List romanNumerals = RomanNumeral.getReverseSortedValues();
+
+ int i = 0;
+ StringBuilder sb = new StringBuilder();
+
+ while (number > 0 && i < romanNumerals.size()) {
+ RomanNumeral currentSymbol = romanNumerals.get(i);
+ if (currentSymbol.getValue() <= number) {
+ sb.append(currentSymbol.name());
+ number -= currentSymbol.getValue();
+ } else {
+ i++;
+ }
+ }
+ return sb.toString();
+ }
+}
diff --git a/algorithms/src/main/java/com/baeldung/algorithms/romannumerals/RomanNumeral.java b/algorithms-miscellaneous-2/src/main/java/com/baeldung/algorithms/romannumerals/RomanNumeral.java
similarity index 96%
rename from algorithms/src/main/java/com/baeldung/algorithms/romannumerals/RomanNumeral.java
rename to algorithms-miscellaneous-2/src/main/java/com/baeldung/algorithms/romannumerals/RomanNumeral.java
index 219f0b5090..2ee5bb6d75 100644
--- a/algorithms/src/main/java/com/baeldung/algorithms/romannumerals/RomanNumeral.java
+++ b/algorithms-miscellaneous-2/src/main/java/com/baeldung/algorithms/romannumerals/RomanNumeral.java
@@ -1,26 +1,26 @@
-package com.baeldung.algorithms.romannumerals;
-
-import java.util.Arrays;
-import java.util.Comparator;
-import java.util.List;
-import java.util.stream.Collectors;
-
-enum RomanNumeral {
- I(1), IV(4), V(5), IX(9), X(10), XL(40), L(50), XC(90), C(100), CD(400), D(500), CM(900), M(1000);
-
- private int value;
-
- RomanNumeral(int value) {
- this.value = value;
- }
-
- public int getValue() {
- return value;
- }
-
- public static List getReverseSortedValues() {
- return Arrays.stream(values())
- .sorted(Comparator.comparing((RomanNumeral e) -> e.value).reversed())
- .collect(Collectors.toList());
- }
-}
+package com.baeldung.algorithms.romannumerals;
+
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.List;
+import java.util.stream.Collectors;
+
+enum RomanNumeral {
+ I(1), IV(4), V(5), IX(9), X(10), XL(40), L(50), XC(90), C(100), CD(400), D(500), CM(900), M(1000);
+
+ private int value;
+
+ RomanNumeral(int value) {
+ this.value = value;
+ }
+
+ public int getValue() {
+ return value;
+ }
+
+ public static List getReverseSortedValues() {
+ return Arrays.stream(values())
+ .sorted(Comparator.comparing((RomanNumeral e) -> e.value).reversed())
+ .collect(Collectors.toList());
+ }
+}
diff --git a/algorithms/src/main/java/com/baeldung/algorithms/sudoku/BacktrackingAlgorithm.java b/algorithms-miscellaneous-2/src/main/java/com/baeldung/algorithms/sudoku/BacktrackingAlgorithm.java
similarity index 100%
rename from algorithms/src/main/java/com/baeldung/algorithms/sudoku/BacktrackingAlgorithm.java
rename to algorithms-miscellaneous-2/src/main/java/com/baeldung/algorithms/sudoku/BacktrackingAlgorithm.java
diff --git a/algorithms/src/main/java/com/baeldung/algorithms/sudoku/ColumnNode.java b/algorithms-miscellaneous-2/src/main/java/com/baeldung/algorithms/sudoku/ColumnNode.java
similarity index 100%
rename from algorithms/src/main/java/com/baeldung/algorithms/sudoku/ColumnNode.java
rename to algorithms-miscellaneous-2/src/main/java/com/baeldung/algorithms/sudoku/ColumnNode.java
diff --git a/algorithms/src/main/java/com/baeldung/algorithms/sudoku/DancingLinks.java b/algorithms-miscellaneous-2/src/main/java/com/baeldung/algorithms/sudoku/DancingLinks.java
similarity index 100%
rename from algorithms/src/main/java/com/baeldung/algorithms/sudoku/DancingLinks.java
rename to algorithms-miscellaneous-2/src/main/java/com/baeldung/algorithms/sudoku/DancingLinks.java
diff --git a/algorithms/src/main/java/com/baeldung/algorithms/sudoku/DancingLinksAlgorithm.java b/algorithms-miscellaneous-2/src/main/java/com/baeldung/algorithms/sudoku/DancingLinksAlgorithm.java
similarity index 100%
rename from algorithms/src/main/java/com/baeldung/algorithms/sudoku/DancingLinksAlgorithm.java
rename to algorithms-miscellaneous-2/src/main/java/com/baeldung/algorithms/sudoku/DancingLinksAlgorithm.java
diff --git a/algorithms/src/main/java/com/baeldung/algorithms/sudoku/DancingNode.java b/algorithms-miscellaneous-2/src/main/java/com/baeldung/algorithms/sudoku/DancingNode.java
similarity index 100%
rename from algorithms/src/main/java/com/baeldung/algorithms/sudoku/DancingNode.java
rename to algorithms-miscellaneous-2/src/main/java/com/baeldung/algorithms/sudoku/DancingNode.java
diff --git a/apache-cayenne/src/main/resources/logback.xml b/algorithms-miscellaneous-2/src/main/resources/logback.xml
similarity index 100%
rename from apache-cayenne/src/main/resources/logback.xml
rename to algorithms-miscellaneous-2/src/main/resources/logback.xml
diff --git a/algorithms-miscellaneous-2/src/main/resources/maze/maze1.txt b/algorithms-miscellaneous-2/src/main/resources/maze/maze1.txt
new file mode 100644
index 0000000000..8b48c325d2
--- /dev/null
+++ b/algorithms-miscellaneous-2/src/main/resources/maze/maze1.txt
@@ -0,0 +1,12 @@
+S ########
+# #
+# ### ## #
+# # # #
+# # # # #
+# ## #####
+# # #
+# # # # #
+##### ####
+# # E
+# # # #
+##########
\ No newline at end of file
diff --git a/algorithms-miscellaneous-2/src/main/resources/maze/maze2.txt b/algorithms-miscellaneous-2/src/main/resources/maze/maze2.txt
new file mode 100644
index 0000000000..df5b6bc66b
--- /dev/null
+++ b/algorithms-miscellaneous-2/src/main/resources/maze/maze2.txt
@@ -0,0 +1,22 @@
+S ##########################
+# # # #
+# # #### ############### #
+# # # # # #
+# # #### # # ###############
+# # # # # # #
+# # # #### ### ########### #
+# # # # # #
+# ################## #
+######### # # # # #
+# # #### # ####### # #
+# # ### ### # # # # #
+# # ## # ##### # #
+##### ####### # # # # #
+# # ## ## #### # #
+# ##### ####### # #
+# # ############
+####### ######### # #
+# # ######## #
+# ####### ###### ## # E
+# # # ## #
+############################
\ No newline at end of file
diff --git a/algorithms/src/test/java/com/baeldung/algorithms/analysis/AnalysisRunnerLiveTest.java b/algorithms-miscellaneous-2/src/test/java/com/baeldung/algorithms/analysis/AnalysisRunnerLiveTest.java
similarity index 100%
rename from algorithms/src/test/java/com/baeldung/algorithms/analysis/AnalysisRunnerLiveTest.java
rename to algorithms-miscellaneous-2/src/test/java/com/baeldung/algorithms/analysis/AnalysisRunnerLiveTest.java
diff --git a/algorithms/src/test/java/com/baeldung/algorithms/conversion/ByteArrayConverterUnitTest.java b/algorithms-miscellaneous-2/src/test/java/com/baeldung/algorithms/conversion/ByteArrayConverterUnitTest.java
similarity index 100%
rename from algorithms/src/test/java/com/baeldung/algorithms/conversion/ByteArrayConverterUnitTest.java
rename to algorithms-miscellaneous-2/src/test/java/com/baeldung/algorithms/conversion/ByteArrayConverterUnitTest.java
diff --git a/algorithms/src/test/java/com/baeldung/algorithms/distancebetweenpoints/DistanceBetweenPointsServiceUnitTest.java b/algorithms-miscellaneous-2/src/test/java/com/baeldung/algorithms/distancebetweenpoints/DistanceBetweenPointsServiceUnitTest.java
similarity index 100%
rename from algorithms/src/test/java/com/baeldung/algorithms/distancebetweenpoints/DistanceBetweenPointsServiceUnitTest.java
rename to algorithms-miscellaneous-2/src/test/java/com/baeldung/algorithms/distancebetweenpoints/DistanceBetweenPointsServiceUnitTest.java
diff --git a/algorithms/src/test/java/com/baeldung/algorithms/editdistance/EditDistanceDataProvider.java b/algorithms-miscellaneous-2/src/test/java/com/baeldung/algorithms/editdistance/EditDistanceDataProvider.java
similarity index 96%
rename from algorithms/src/test/java/com/baeldung/algorithms/editdistance/EditDistanceDataProvider.java
rename to algorithms-miscellaneous-2/src/test/java/com/baeldung/algorithms/editdistance/EditDistanceDataProvider.java
index 89bd871616..d11da61191 100644
--- a/algorithms/src/test/java/com/baeldung/algorithms/editdistance/EditDistanceDataProvider.java
+++ b/algorithms-miscellaneous-2/src/test/java/com/baeldung/algorithms/editdistance/EditDistanceDataProvider.java
@@ -1,21 +1,21 @@
-package com.baeldung.algorithms.editdistance;
-
-import org.junit.runners.Parameterized.Parameters;
-
-import java.util.Arrays;
-import java.util.Collection;
-
-public class EditDistanceDataProvider {
-
- @Parameters
- public static Collection