Giter Club home page Giter Club logo

sorting's Introduction

Python sorting algorithms

Implementation of 8 different sorting algorithms in Python:

  • Selection sort
  • Bubble sort
  • Quick sort
  • Heap sort
  • Insertion sort
  • Merge sort
  • Shell sort
  • Pancake sort

Algorithm Descriptions

Selection Sort

Selection sort is a simple sorting algorithm that sorts an array by repeatedly finding the minimum element from the unsorted part of the array and putting it at the beginning. The algorithm maintains two subarrays: the sorted subarray, which is initially empty, and the unsorted subarray, which is initially the entire input array.

Bubble Sort

Bubble sort is a simple sorting algorithm that repeatedly steps through the list, compares adjacent elements and swaps them if they are in the wrong order. The pass through the list is repeated until the list is sorted.

Quick Sort

Quick sort is a divide-and-conquer algorithm that works by selecting a 'pivot' element from the array and partitioning the other elements into two sub-arrays, according to whether they are less than or greater than the pivot. The sub-arrays are then sorted recursively.

Heap Sort

Heap sort is a comparison-based sorting algorithm that uses a binary heap data structure to sort an array. The algorithm divides the input into a sorted and an unsorted region, and it iteratively shrinks the unsorted region by extracting the largest element from it and moving that to the sorted region.

Insertion Sort

Insertion sort is a simple sorting algorithm that builds the final sorted array one item at a time. It is much less efficient on large lists than more advanced algorithms such as quicksort, heapsort, or merge sort.

Merge Sort

Merge sort is a divide-and-conquer algorithm that works by dividing the input array into two halves, sorting each half recursively, and then merging the two sorted halves.

Shell Sort

Shell sort is a generalization of insertion sort that allows the exchange of items that are far apart. The method starts by sorting pairs of elements far apart from each other, then progressively reducing the gap between elements to be compared.

Pancake Sort

Pancake sort is a variation of selection sort that sorts an array by repeatedly flipping the largest element to the beginning of the array, and then flipping the entire array to move the largest element to its correct position.

sorting's People

Contributors

belkius avatar

Stargazers

Bartosz Preiniger 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.