Features · Project Structure · Architecture · Getting Started · Docker · Kubernetes · Testing · Benchmarking · Security · Contributing · License · Versioning
Comprehensive Collection of Bubble Sort Algorithms Implemented in JavaScript with Extensive Design Patterns, Testing & DevOps Practices
- Multiple Implementations: Classic, Optimized, and Recursive bubble sort
- Design Patterns: Template Method, Strategy, Factory patterns
- Comprehensive Testing: Unit tests with Jest
- Performance Benchmarking: Detailed performance analysis
- Structured Logging: Winston-based logging
- CI/CD Pipeline: GitHub Actions workflow
- Containerization: Docker and Kubernetes support
- Code Quality: ESLint, Prettier, pre-commit hooks
├── src/
│ ├── core/ # Abstract base classes
│ ├── implementations/ # Concrete bubble sort implementations
│ ├── strategies/ # Comparison strategies
│ ├── factory/ # Factory pattern implementations
│ └── utils/ # Utilities and logging
├── tests/ # Unit tests
├── benchmarks/ # Performance benchmarks
├── .github/ # GitHub workflows and templates
├── docs/ # Documentation
└── k8s/ # Kubernetes manifests
- Template Method Pattern:
BubbleSortbase class defines algorithm structure - Strategy Pattern:
ComparatorStrategyfor flexible comparison logic - Factory Pattern:
SorterFactoryfor creating different implementations
| Implementation | Time (Best) | Time (Average) | Time (Worst) | Space |
|---|---|---|---|---|
| Classic | O(n²) | O(n²) | O(n²) | O(1) |
| Optimized | O(n) | O(n²) | O(n²) | O(1) |
| Recursive | O(n²) | O(n²) | O(n²) | O(n) |
- Node.js 16+
- Docker (optional)
- Kubernetes (optional)
# Clone repository
git clone https://github.com/WillKirkmanM/bubblesort.git
cd bubblesort
# Install dependencies
npm install
# Run tests
npm test
# Run benchmarks
npm run benchmarkconst SorterFactory = require('./src/factory/SorterFactory');
// Create different implementations
const classicSorter = SorterFactory.createSorter('classic');
const optimizedSorter = SorterFactory.createSorter('optimized');
// Sort arrays
const sorted = classicSorter.sort([3, 1, 4, 1, 5, 9, 2, 6]);
console.log(sorted); // [1, 1, 2, 3, 4, 5, 6, 9]
// Get performance metrics
const metrics = classicSorter.getMetrics();
console.log(`Comparisons: ${metrics.comparisons}, Swaps: ${metrics.swaps}`);# Build image
docker build -t bubblesort-app .
# Run container
docker run -p 3000:3000 bubblesort-app
# Using docker-compose
docker-compose upkubectl apply -f k8s/# Run all tests
npm test
# Run with coverage
npm run test:coverage
# Watch mode
npm run test:watchThe project includes comprehensive benchmarks comparing all implementations:
npm run benchmarkResults are logged with structured data including operations per second and statistical analysis.
See SECURITY.md for security policies and vulnerability reporting.
Please read CONTRIBUTING.md for details on our code of conduct and the process for submitting pull requests.
This project is licensed under the MIT License - see the LICENSE file for details.
We use SemVer for versioning. For available versions, see the tags on this repository.