Skip to content

Comprehensive Collection of Bubble Sort Algorithms Implemented in JavaScript with Extensive Design Patterns, Testing & DevOps Practices

License

Notifications You must be signed in to change notification settings

WillKirkmanM/bubbleSort

Repository files navigation

Bubble Sort

Comprehensive Collection of Bubble Sort Algorithms Implemented in JavaScript with Extensive Design Patterns, Testing & DevOps Practices

Features

  • 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

Project Structure

├── 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

Architecture

Design Patterns Used

  1. Template Method Pattern: BubbleSort base class defines algorithm structure
  2. Strategy Pattern: ComparatorStrategy for flexible comparison logic
  3. Factory Pattern: SorterFactory for creating different implementations

Time & Space Complexity

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)

Getting Started

Prerequisites

  • Node.js 16+
  • Docker (optional)
  • Kubernetes (optional)

Installation

# Clone repository
git clone https://github.com/WillKirkmanM/bubblesort.git
cd bubblesort

# Install dependencies
npm install

# Run tests
npm test

# Run benchmarks
npm run benchmark

Usage

const 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}`);

Docker Usage

# Build image
docker build -t bubblesort-app .

# Run container
docker run -p 3000:3000 bubblesort-app

# Using docker-compose
docker-compose up

Kubernetes Deployment

kubectl apply -f k8s/

Testing

# Run all tests
npm test

# Run with coverage
npm run test:coverage

# Watch mode
npm run test:watch

Benchmarking

The project includes comprehensive benchmarks comparing all implementations:

npm run benchmark

Results are logged with structured data including operations per second and statistical analysis.

Security

See SECURITY.md for security policies and vulnerability reporting.

Contributing

Please read CONTRIBUTING.md for details on our code of conduct and the process for submitting pull requests.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Versioning

We use SemVer for versioning. For available versions, see the tags on this repository.

About

Comprehensive Collection of Bubble Sort Algorithms Implemented in JavaScript with Extensive Design Patterns, Testing & DevOps Practices

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy