Giter Site home page Giter Site logo

types-of-sorting's Introduction

This repository contains a single .py file that contains 5 basic sorting techniques

Bubble Sort : (In place - sorting)

Best case : O(n)
Worst case : O(n^2)
Inefficient for Large Datasets.
Bubble sort is three times slower than QuickSort for n = 100

Selection Sort : (In place - sorting)

Worst case, Best case : O(n^2)
Inefficient for Large Datasets.

Insertion Sort : (In place - sorting)

Best case : O(n)
Worst case : O(n^2)
Efficient for small datasets and partially sorted arrays.

Merge Sort : (Comparison and recursive based)

All cases : O(n log n)
Efficient, stable, suitable for large datasets (Divide and Conquer).

Quick Sort : (Recursion based)

Average case : O(n log n)
Worst case : O(n^2)
Efficient, widely used and reduces space usage.

Heap Sort : (In place - sorting)

All cases : O(n log n)
Efficient but not stable.

Counting Sort : (Not in place)

All cases : O(n + k) ; K is the range of input.
Efficient for sorting non-negative integers with a small range but requires extra memory

Radix Sort : (Not in place)

All cases : O(d * (n + k)) ; d โ†’ number of digits in max number, k is range of input.
Suitable for sorting integers with fixed number of digits.

Bucket Sort : (Not in place)

Worst case : O(n^2), but can be linear with good choice of hash func.
Efficient when data is uniformly distributed across buckets.

Tim Sort : (Not in place)

All cases : O(n log n)
A hybrid sorting algorithm derived from Merge sort and Insertion sort. In python it is "sorted()".

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.