Stalin Sort

Add a stalin sort algorithm in any language you like ❣️ if you like give us a ⭐️
Alternatives To Stalin Sort
Project NameStarsDownloadsRepos Using ThisPackages Using ThisMost Recent CommitTotal ReleasesLatest ReleaseOpen IssuesLicenseLanguage
Javascript Algorithms165,43625 days ago4June 02, 2018294mitJavaScript
📝 Algorithms and data structures implemented in JavaScript with explanations and links to further readings
Python156,086
15 hours ago146mitPython
All Algorithms implemented in Python
Java50,905
19 hours ago17mitJava
All Algorithms implemented in Java
Javascript25,805
8 days ago32gpl-3.0JavaScript
Algorithms and Data Structures implemented in JavaScript for beginners, following best practices.
C Plus Plus23,758
12 hours ago41mitC++
Collection of various algorithms in mathematics, machine learning, computer science and physics implemented in C++ for educational purposes.
Algorithms22,27414118 days ago5October 04, 2020200mitPython
Minimal examples of data structures and algorithms in Python
C15,880
12 hours ago24gpl-3.0C
Collection of various algorithms in mathematics, machine learning, computer science, physics, etc implemented in C for educational purposes.
Tech Interview For Developer10,098
3 days ago2mitJava
👶🏻 신입 개발자 전공 지식 & 기술 면접 백과사전 📖
Algoxy5,568
14 hours ago2TeX
Book of Elementary Algorithms and Data structures
C Sharp Algorithms5,068
6 months ago1August 14, 202147mitC#
:books: :chart_with_upwards_trend: Plug-and-play class-library project of standard Data Structures and Algorithms in C#
Alternatives To Stalin Sort
Select To Compare


Alternative Project Comparisons
Readme

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.

Popular Algorithms Projects
Popular Sort Projects
Popular Computer Science Categories
Related Searches

Get A Weekly Email With Trending Projects For These Categories
No Spam. Unsubscribe easily at any time.
Algorithms
Sort
Coq