Giter Site home page Giter Site logo

redsolver / stalin-sort Goto Github PK

View Code? Open in Web Editor NEW

This project forked from gustavo-depaula/stalin-sort

0.0 2.0 0.0 914 KB

Add a stalin sort algorithm in any language you like ❣️ if you like give us a ⭐️

License: MIT License

JavaScript 2.10% C 2.64% Python 21.78% Go 5.24% Ruby 1.38% Kotlin 4.15% C# 14.81% Gnuplot 0.36% Haskell 1.85% Brainfuck 0.88% Java 6.37% Haxe 1.53% Perl 3.68% PHP 1.22% Swift 3.43% Erlang 0.90% Standard ML 2.10% C++ 22.48% Lua 1.01% Common Lisp 2.07%

stalin-sort's Introduction

Welcome to the Stalin Sort Repo 📋

poster

What is Stalin Sort? ❓

Introduction

Stalin Sort is an efficient sorting algorithm, serving as a systematic method for placing the elements of a random access file or an array in order. Stalin Sort is also know as the best sorting algorithm of all times because of its AMAZING capacity of always ordering an array with an O(n) performance.

How it works?

It's simple, all you need to do is iterate through the array, checking if its elements are in order. Any element that isn't in order you pull out, in other words, you send it to Gulag.

Step-by-step example

  1. (1 2 5 3 5 7) -> (1 2 5 3 5 7) Here the algorithm stores the first of element of the array
  2. (1 2 5 3 5 7) -> (1 2 5 3 5 7) Now it will compare the stored element with the second one, if this is bigger than the stored, it replaces the stored element by this
  3. (1 2 5 3 5 7) -> (1 2 5 3 5 7) Repeats step 2
  4. (1 2 5 3 5 7) -> (1 2 5 5 7) Since the 4th element is smaller than the 3rd one, the 4th element will be eliminated.
  5. (1 2 5 5 7) -> (1 2 5 5 7) Equal elements are preserved
  6. (1 2 5 5 7) Ordered array!

Pseudocode implementation

Keep in mind that this is pseudocode, and is just an example. We strongly encourage you to code a different approach.

FUNCTION stalinSort(A : list OF sortable items)
    n := length(A)
    bigger := 0
    B SET empty list

    FOR i := 0 TO n NOT inclusive DO
        IF A[i] >= bigger THEN
          bigger := A[i]
          B.push(A[i])
        END IF
    END FOR

    RETURN B
END FUNCTION

Want to help? 🙌

Please check the CONTRIBUTING.md

Give this Project a Star! ⭐

About

Stalin sort began first as a Hacktoberfest 2018 repo

Hacktoberfest is a program organised by Digital Ocean and Github, where you can easily win a T-Shirt just by making 5 pull requests in the month of October to any open source projects on Github.

stalin-sort's People

Contributors

gustavo-depaula avatar gabrielcarneiro97 avatar wpwoodjr avatar mogron avatar gaburielcasado avatar nagataaaas avatar luksamuk avatar 89netram avatar alphya avatar plokmijnuhby avatar victorperin avatar kentarousuzuki avatar watosar avatar tmaxthomas avatar dxeoane avatar uhthomas avatar robthree avatar cykooz avatar ktakahiro1729 avatar vijiatjack avatar nickproud avatar bluoxy avatar vprjct avatar ry-itto avatar lionrouge avatar freeonterminate avatar erkin avatar arkadye avatar akiakishitai avatar bokutin avatar

Watchers

James Cloos avatar  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.