Giter Site home page Giter Site logo

softuni-algorithms-fundamentals-november-2020's Introduction

Sorting Algorithms

Name Best Average Worst Memory Stable Method
Selection Sort n2 n2 n2 1 No Selection
Bubble Sort n n2 n2 1 Yes Exchanging
Insertion Sort n n2 n2 1 Yes Insertion
Merge Sort n*log(n) n*log(n) n*log(n) 1 (or n) Yes Merging
Quick Sort n*log(n) n*log(n) n2 log(n) Depends Partitioning

Selection Sort

Selection Sort

Simple, but inefficient algorithm. Swap the first with the min element on the right, then the second, etc.

  • Memory: O(1)
  • Stable: No
  • Method: Selection

Bubble Sort

Bubble Sort

Simple, but inefficient algorithm. Swaps to neighbor elements when not in order until sorted.

  • Memory: O(1)
  • Stable: Yes
  • Method: Exchanging

Insertion Sort

Insertion Sort

Simple, but inefficient algorithm. Move the first unsorted element left to its place.

  • Memory: O(1)
  • Stable: Yes
  • Method: Insertion

Merge Sort

Merge Sort

Efficient sorting algorithm.

  1. Divide the list into sub-lists (typically 2 sub-lists)
  2. Sort each sub-list (recursively call merge-sort)
  3. Merge the sorted sub-lists into a single list

Best, average and worst case: O(n*log(n))

  • Memory: O(n) / O(1)
  • Stable: Yes
  • Method: Merging

Quick Sort

Quick Sort

Quick Sort

Efficient sorting algorithm.

  1. Choose a pivot
  2. Move smaller elements left & larger right
  3. sort left & right

Best & average case: O(n*log(n)); Worst: O(n2)

  • Memory: O(log(n))
  • Stable: Depends
  • Method: Partitioning

softuni-algorithms-fundamentals-november-2020's People

Contributors

boykopetevboev avatar

Stargazers

Roman avatar

Watchers

James Cloos avatar  avatar

Forkers

ashleanichols

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.