GithubHelp home page GithubHelp logo

acs-3310-final's Introduction

TypeScript Sorting Algorithms

A collection of sorting algorithms implemented in TypeScript.

Installation

npm i @mfx2/sorting-algorithms-utility
const sorter = new Sorter();
const unsortedArray = [64, 34, 25, 12, 22, 11, 90];

// Using Bubble Sort
const bubbleSorted = sorter.bubbleSort([...unsortedArray]);
console.log('Bubble Sort:', bubbleSorted);

// Using Merge Sort
const mergeSorted = sorter.mergeSort([...unsortedArray]);
console.log('Merge Sort:', mergeSorted);

// Using Quick Sort
const quickSorted = sorter.quickSort([...unsortedArray]);
console.log('Quick Sort:', quickSorted);

// Using Heap Sort
const heapSorted = sorter.heapSort([...unsortedArray]);
console.log('Heap Sort:', heapSorted);

// Using Selection Sort
const selectionSorted = sorter.selectionSort([...unsortedArray]);
console.log('Selection Sort:', selectionSorted);

// Using Insertion Sort
const insertionSorted = sorter.insertionSort([...unsortedArray]);
console.log('Insertion Sort:', insertionSorted);

Available Sorting Algorithms

  • Bubble Sort: bubbleSort(array: number[]): number[]
  • Merge Sort: mergeSort(array: number[]): number[]
  • Quick Sort: quickSort(array: number[]): number[]
  • Heap Sort: heapSort(array: number[]): number[]
  • Selection Sort: selectionSort(array: number[]): number[]
  • Insertion Sort: insertionSort(array: number[]): number[]

Each sorting method takes an array of numbers as input and returns a sorted array.

Performance

The time complexity of these sorting algorithms varies:

  • Bubble Sort: O(n²)
  • Merge Sort: O(n log n)
  • Quick Sort: O(n log n) average case, O(n²) worst case
  • Heap Sort: O(n log n)
  • Selection Sort: O(n²)
  • Insertion Sort: O(n²)

acs-3310-final's People

Contributors

fraziermark avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.