|
| 1 | +<p align="center"> |
| 2 | + <img src="https://avatars.githubusercontent.com/u/138057124?s=200&v=4" width="150" /> |
| 3 | +</p> |
| 4 | +<h1 align="center">Bubble Sort</h1> |
| 5 | + |
| 6 | +<h4 align="center"> |
| 7 | + <a href=""></a> |
| 8 | +</h4> |
| 9 | + |
| 10 | +<h4 align="center"> |
| 11 | + <a href="#-features">Features</a> |
| 12 | + · |
| 13 | + <a href="#-project-structure">Project Structure</a> |
| 14 | + · |
| 15 | + <a href="#️-architecture">Architecture</a> |
| 16 | + · |
| 17 | + <a href="#-getting-started">Getting Started</a> |
| 18 | + · |
| 19 | + <a href="#-docker-usage">Docker</a> |
| 20 | + · |
| 21 | + <a href="#️-kubernetes-deployment">Kubernetes</a> |
| 22 | + · |
| 23 | + <a href="#-testing">Testing</a> |
| 24 | + · |
| 25 | + <a href="#-benchmarking">Benchmarking</a> |
| 26 | + · |
| 27 | + <a href="#-security">Security</a> |
| 28 | + · |
| 29 | + <a href="#-contributing">Contributing</a> |
| 30 | + · |
| 31 | + <a href="#-license">License</a> |
| 32 | + · |
| 33 | + <a href="#️-versioning">Versioning</a> |
| 34 | +</h4> |
| 35 | + |
| 36 | +<p align="center">Comprehensive Collection of Bubble Sort Algorithms Implemented in JavaScript with Extensive Design Patterns, Testing & DevOps Practices</p> |
| 37 | + |
| 38 | +## Features |
| 39 | + |
| 40 | +- **Multiple Implementations**: Classic, Optimized, and Recursive bubble sort |
| 41 | +- **Design Patterns**: Template Method, Strategy, Factory patterns |
| 42 | +- **Comprehensive Testing**: Unit tests with Jest |
| 43 | +- **Performance Benchmarking**: Detailed performance analysis |
| 44 | +- **Structured Logging**: Winston-based logging |
| 45 | +- **CI/CD Pipeline**: GitHub Actions workflow |
| 46 | +- **Containerization**: Docker and Kubernetes support |
| 47 | +- **Code Quality**: ESLint, Prettier, pre-commit hooks |
| 48 | + |
| 49 | +## Project Structure |
| 50 | + |
| 51 | +``` |
| 52 | +├── src/ |
| 53 | +│ ├── core/ # Abstract base classes |
| 54 | +│ ├── implementations/ # Concrete bubble sort implementations |
| 55 | +│ ├── strategies/ # Comparison strategies |
| 56 | +│ ├── factory/ # Factory pattern implementations |
| 57 | +│ └── utils/ # Utilities and logging |
| 58 | +├── tests/ # Unit tests |
| 59 | +├── benchmarks/ # Performance benchmarks |
| 60 | +├── .github/ # GitHub workflows and templates |
| 61 | +├── docs/ # Documentation |
| 62 | +└── k8s/ # Kubernetes manifests |
| 63 | +``` |
| 64 | + |
| 65 | +## Architecture |
| 66 | + |
| 67 | +### Design Patterns Used |
| 68 | + |
| 69 | +1. **Template Method Pattern**: `BubbleSort` base class defines algorithm structure |
| 70 | +2. **Strategy Pattern**: `ComparatorStrategy` for flexible comparison logic |
| 71 | +3. **Factory Pattern**: `SorterFactory` for creating different implementations |
| 72 | + |
| 73 | +### Time & Space Complexity |
| 74 | + |
| 75 | +| Implementation | Time (Best) | Time (Average) | Time (Worst) | Space | |
| 76 | +|---------------|-------------|----------------|--------------|-------| |
| 77 | +| Classic | O(n²) | O(n²) | O(n²) | O(1) | |
| 78 | +| Optimized | O(n) | O(n²) | O(n²) | O(1) | |
| 79 | +| Recursive | O(n²) | O(n²) | O(n²) | O(n) | |
| 80 | + |
| 81 | +## Getting Started |
| 82 | + |
| 83 | +### Prerequisites |
| 84 | + |
| 85 | +- Node.js 16+ |
| 86 | +- Docker (optional) |
| 87 | +- Kubernetes (optional) |
| 88 | + |
| 89 | +### Installation |
| 90 | + |
| 91 | +```bash |
| 92 | +# Clone repository |
| 93 | +git clone https://github.com/WillKirkmanM/bubblesort.git |
| 94 | +cd bubblesort |
| 95 | + |
| 96 | +# Install dependencies |
| 97 | +npm install |
| 98 | + |
| 99 | +# Run tests |
| 100 | +npm test |
| 101 | + |
| 102 | +# Run benchmarks |
| 103 | +npm run benchmark |
| 104 | +``` |
| 105 | + |
| 106 | +### Usage |
| 107 | + |
| 108 | +```javascript |
| 109 | +const SorterFactory = require('./src/factory/SorterFactory'); |
| 110 | + |
| 111 | +// Create different implementations |
| 112 | +const classicSorter = SorterFactory.createSorter('classic'); |
| 113 | +const optimizedSorter = SorterFactory.createSorter('optimized'); |
| 114 | + |
| 115 | +// Sort arrays |
| 116 | +const sorted = classicSorter.sort([3, 1, 4, 1, 5, 9, 2, 6]); |
| 117 | +console.log(sorted); // [1, 1, 2, 3, 4, 5, 6, 9] |
| 118 | + |
| 119 | +// Get performance metrics |
| 120 | +const metrics = classicSorter.getMetrics(); |
| 121 | +console.log(`Comparisons: ${metrics.comparisons}, Swaps: ${metrics.swaps}`); |
| 122 | +``` |
| 123 | + |
| 124 | +## Docker Usage |
| 125 | + |
| 126 | +```bash |
| 127 | +# Build image |
| 128 | +docker build -t bubblesort-app . |
| 129 | + |
| 130 | +# Run container |
| 131 | +docker run -p 3000:3000 bubblesort-app |
| 132 | + |
| 133 | +# Using docker-compose |
| 134 | +docker-compose up |
| 135 | +``` |
| 136 | + |
| 137 | +## Kubernetes Deployment |
| 138 | + |
| 139 | +```bash |
| 140 | +kubectl apply -f k8s/ |
| 141 | +``` |
| 142 | + |
| 143 | +## Testing |
| 144 | + |
| 145 | +```bash |
| 146 | +# Run all tests |
| 147 | +npm test |
| 148 | + |
| 149 | +# Run with coverage |
| 150 | +npm run test:coverage |
| 151 | + |
| 152 | +# Watch mode |
| 153 | +npm run test:watch |
| 154 | +``` |
| 155 | + |
| 156 | +## Benchmarking |
| 157 | + |
| 158 | +The project includes comprehensive benchmarks comparing all implementations: |
| 159 | + |
| 160 | +```bash |
| 161 | +npm run benchmark |
| 162 | +``` |
| 163 | + |
| 164 | +Results are logged with structured data including operations per second and statistical analysis. |
| 165 | + |
| 166 | +## Security |
| 167 | + |
| 168 | +See [SECURITY.md](SECURITY.md) for security policies and vulnerability reporting. |
| 169 | + |
| 170 | +## Contributing |
| 171 | + |
| 172 | +Please read [CONTRIBUTING.md](CONTRIBUTING.md) for details on our code of conduct and the process for submitting pull requests. |
| 173 | + |
| 174 | +## License |
| 175 | + |
| 176 | +This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details. |
| 177 | + |
| 178 | +## Versioning |
| 179 | + |
| 180 | +We use [SemVer](http://semver.org/) for versioning. For available versions, see the [tags on this repository](https://github.com/yourusername/bubblesort-implementations/tags). |
0 commit comments