Skip to content

Commit d2fd54f

Browse files
committed
Fixed conflict
2 parents 97de755 + 7940f0d commit d2fd54f

File tree

703 files changed

+10376
-6963
lines changed

Some content is hidden

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

703 files changed

+10376
-6963
lines changed

.gitignore

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,4 +84,10 @@ software-security/sql-injection-samples/derby.log
8484
spring-soap/src/main/java/com/baeldung/springsoap/gen/
8585
/report-*.json
8686
transaction.log
87-
*-shell.log
87+
*-shell.log
88+
89+
apache-cxf/cxf-aegis/baeldung.xml
90+
apache-fop/src/test/resources/input.xml
91+
apache-fop/src/test/resources/output_herold.pdf
92+
apache-fop/src/test/resources/output_html2fo.pdf
93+
apache-fop/src/test/resources/output_jtidy.pdf

akka-http/README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1-
## Relevant articles:
1+
## Akka HTTP
2+
3+
This module contains articles about Akka HTTP.
4+
5+
### Relevant articles:
26

37
- [Introduction to Akka HTTP](https://www.baeldung.com/akka-http)

akka-streams/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## Akka Streams
2+
3+
This module contains articles about Akka Streams.
4+
15
### Relevant articles
26

37
- [Guide to Akka Streams](https://www.baeldung.com/akka-streams)

algorithms-genetic/README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
## Relevant articles:
1+
## Genetic Algorithms
2+
3+
This module contains articles about genetic algorithms.
4+
5+
### Relevant articles:
26

37
- [Introduction to Jenetics Library](https://www.baeldung.com/jenetics)
48
- [Ant Colony Optimization](https://www.baeldung.com/java-ant-colony-optimization)

algorithms-miscellaneous-1/README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
1-
## Relevant articles:
1+
## Algorithms - Miscellaneous
2+
3+
This module contains articles about algorithms. Some classes of algorithms, e.g., [sorting](/../algorithms-sorting) and
4+
[genetic algorithms](/../algorithms-genetic), have their own dedicated modules.
5+
6+
### Relevant articles:
27

38
- [Validating Input With Finite Automata in Java](https://www.baeldung.com/java-finite-automata)
49
- [Example of Hill Climbing Algorithm](https://www.baeldung.com/java-hill-climbing-algorithm)
510
- [Monte Carlo Tree Search for Tic-Tac-Toe Game](https://www.baeldung.com/java-monte-carlo-tree-search)
611
- [Binary Search Algorithm in Java](https://www.baeldung.com/java-binary-search)
712
- [Introduction to Minimax Algorithm](https://www.baeldung.com/java-minimax-algorithm)
813
- [How to Calculate Levenshtein Distance in Java?](https://www.baeldung.com/java-levenshtein-distance)
9-
- [How to Find the Kth Largest Element in Java](https://www.baeldung.com/java-kth-largest-element)
14+
- [How to Find the Kth Largest Element in Java](https://www.baeldung.com/java-kth-largest-element)
15+
- More articles: [[next -->]](/../algorithms-miscellaneous-2)

algorithms-miscellaneous-2/README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
## Relevant articles:
1+
## Algorithms - Miscellaneous
2+
3+
This module contains articles about algorithms. Some classes of algorithms, e.g., [sorting](/../algorithms-sorting) and
4+
[genetic algorithms](/../algorithms-genetic), have their own dedicated modules.
5+
6+
### Relevant articles:
27

38
- [Dijkstra Shortest Path Algorithm in Java](https://www.baeldung.com/java-dijkstra)
49
- [Introduction to Cobertura](https://www.baeldung.com/cobertura)
@@ -8,3 +13,4 @@
813
- [Create a Sudoku Solver in Java](https://www.baeldung.com/java-sudoku)
914
- [Displaying Money Amounts in Words](https://www.baeldung.com/java-money-into-words)
1015
- [A Collaborative Filtering Recommendation System in Java](https://www.baeldung.com/java-collaborative-filtering-recommendations)
16+
- More articles: [[<-- prev]](/../algorithms-miscellaneous-1) [[next -->]](/../algorithms-miscellaneous-3)

algorithms-miscellaneous-3/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,6 @@ This module contains articles about algorithms. Some classes of algorithms, e.g.
1616
- [Efficient Word Frequency Calculator in Java](https://www.baeldung.com/java-word-frequency)
1717
- [Interpolation Search in Java](https://www.baeldung.com/java-interpolation-search)
1818
- [The K-Means Clustering Algorithm in Java](https://www.baeldung.com/java-k-means-clustering-algorithm)
19+
- [Creating a Custom Annotation in Java](https://www.baeldung.com/java-custom-annotation)
20+
- [Breadth-First Search Algorithm in Java](https://www.baeldung.com/java-breadth-first-search)
1921
- More articles: [[<-- prev]](/algorithms-miscellaneous-2) [[next -->]](/algorithms-miscellaneous-4)

algorithms-miscellaneous-4/README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
1-
## Relevant articles:
1+
## Algorithms - Miscellaneous
2+
3+
This module contains articles about algorithms. Some classes of algorithms, e.g., [sorting](https://github.com/eugenp/tutorials/blob/algorithms-sorting) and [genetic algorithms](https://github.com/eugenp/tutorials/blob/algorithms-genetic), have their own dedicated modules.
4+
5+
### Relevant articles:
26

37
- [Multi-Swarm Optimization Algorithm in Java](https://www.baeldung.com/java-multi-swarm-algorithm)
48
- [String Search Algorithms for Large Texts](https://www.baeldung.com/java-full-text-search-algorithms)
59
- [Check If a String Contains All The Letters of The Alphabet](https://www.baeldung.com/java-string-contains-all-letters)
610
- [Find the Middle Element of a Linked List](https://www.baeldung.com/java-linked-list-middle-element)
711
- [Find Substrings That Are Palindromes in Java](https://www.baeldung.com/java-palindrome-substrings)
812
- [Find the Longest Substring without Repeating Characters](https://www.baeldung.com/java-longest-substring-without-repeated-characters)
9-
- [Permutations of an Array in Java](https://www.baeldung.com/java-array-permutations)
13+
- [Permutations of an Array in Java](https://www.baeldung.com/java-array-permutations)
14+
- More articles: [[<-- prev]](/algorithms-miscellaneous-3) [[next -->]](/algorithms-miscellaneous-5)

algorithms-miscellaneous-5/README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
1-
## Relevant articles:
1+
## Algorithms - Miscellaneous
2+
3+
This module contains articles about algorithms. Some classes of algorithms, e.g., [sorting](/../algorithms-sorting) and
4+
[genetic algorithms](/../algorithms-genetic), have their own dedicated modules.
5+
6+
### Relevant articles:
27

38
- [Converting Between Byte Arrays and Hexadecimal Strings in Java](https://www.baeldung.com/java-byte-arrays-hex-strings)
49
- [Reversing a Binary Tree in Java](https://www.baeldung.com/java-reversing-a-binary-tree)
5-
- [Find If Two Numbers Are Relatively Prime in Java](https://www.baeldung.com/java-two-relatively-prime-numbers)
10+
- [Find If Two Numbers Are Relatively Prime in Java](https://www.baeldung.com/java-two-relatively-prime-numbers)
11+
- More articles: [[<-- prev]](/../algorithms-miscellaneous-4)
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package com.baeldung.algorithms.knapsack;
2+
3+
public class Knapsack {
4+
5+
public int knapsackRec(int[] w, int[] v, int n, int W) {
6+
if (n <= 0) {
7+
return 0;
8+
} else if (w[n - 1] > W) {
9+
return knapsackRec(w, v, n - 1, W);
10+
} else {
11+
return Math.max(knapsackRec(w, v, n - 1, W), v[n - 1] + knapsackRec(w, v, n - 1, W - w[n - 1]));
12+
}
13+
}
14+
15+
public int knapsackDP(int[] w, int[] v, int n, int W) {
16+
if (n <= 0 || W <= 0) {
17+
return 0;
18+
}
19+
20+
int[][] m = new int[n + 1][W + 1];
21+
for (int j = 0; j <= W; j++) {
22+
m[0][j] = 0;
23+
}
24+
25+
for (int i = 1; i <= n; i++) {
26+
for (int j = 1; j <= W; j++) {
27+
if (w[i - 1] > j) {
28+
m[i][j] = m[i - 1][j];
29+
} else {
30+
m[i][j] = Math.max(m[i - 1][j], m[i - 1][j - w[i - 1]] + v[i - 1]);
31+
}
32+
}
33+
}
34+
return m[n][W];
35+
}
36+
}

0 commit comments

Comments
 (0)