Add all 23 GoF design pattern implementations (2026-06-13)

This commit is contained in:
Ankur
2026-06-13 21:44:56 +05:30
commit a5beb61425
106 changed files with 2977 additions and 0 deletions

View File

@@ -0,0 +1,12 @@
package strategy;
public class BubbleSort implements SortStrategy {
@Override
public void sort(int[] data) {
System.out.println(" [BubbleSort] O(n²) — small arrays only");
for (int i = 0; i < data.length - 1; i++)
for (int j = 0; j < data.length - 1 - i; j++)
if (data[j] > data[j + 1]) { int t = data[j]; data[j] = data[j+1]; data[j+1] = t; }
}
@Override public String getName() { return "BubbleSort"; }
}