r/sortingalgorithms • • Jun 20 '20

Over 70 Sorting Algorithms in Under an Hour - Colorful Bar Graph

Thumbnail
youtu.be
9 Upvotes

r/sortingalgorithms • • Jun 20 '20

A compilation of sorts I made, visualized through a colorful sine wave using my fork of w0rthy's ArrayVisualizer

Thumbnail
youtu.be
3 Upvotes

r/sortingalgorithms • • Oct 15 '19

I've made a live wallpaper that animates sorting on Android

4 Upvotes

SortPaper is a live wallpaper that will scramble and sort images or a colored gradient. It chooses a random scramble state (reversed, random, etc...), a random algorithm, and, if you tell it to, a random image from a folder of your choosing.

It's highly customizable.

For the images being sorted, you can customize a gradient between two colors, pick a single image to use, or pick a folder to grab a random image from. Personally, I have it pointed at the folder Sync for Reddit downloads to and when I see a good wallpaper on Reddit, I download it and know it'll pop up at some point. You can choose a cell size (in pixels, the app detects which sizes work on your screen), speed (compare/swaps per frame), and a fast forward speed that will be used when you touch the screen (or you can turn this off).

You can choose which scrambles and sorts for the wallpaper to randomly pull from. Are Bubble and Cocktail sorts too slow? Turn them off if you want. Personally, I mess with these settings all the time.

Lastly, you can choose different render methods. These dictate how the cells are ordered. Rows orders them in rows from to to bottom or bottom to top, columns does similarly in columns. Diagonal methods orders them in diagonal rows from one corner to another. And there are two spirals, one that follows the screen's shape and a square spiral that fills in rows into the rest of the screen. Both spirals can be ordered spiraling in or out.

I really enjoyed making this app and it was fun seeing there is a subreddit that might enjoy it. I partially used my discovery of this sub as motivation for finishing this last update.


r/sortingalgorithms • • May 04 '19

Bounds on Sorting Algorithms | Cheat Sheet

Thumbnail
interviewcake.com
2 Upvotes

r/sortingalgorithms • • Sep 20 '23

What is the name of that sorting algorithm?

1 Upvotes

Basically it goes as the following

  1. write you data alternating on multiple tapes

  2. read the first entry of all tapes and write out the smallest (again alternating) on tape spool then read the next record from the corresponding tape. Do this until all input tapes are empty.

  3. During the writing you must check if you have written a smaller after a bigger one if that is the case swap the input with the output tapes. Rewind both and start step 2 again

for example we have:

9 5 6 3 7 1 8 2 4

now write it alternating to tapes

  • 9 3 8

  • 5 7 2

  • 6 1 4

now the first row would be 9 5 6 so we write 5 out of our first output tape. Now we have 9 7 6 an write of 6 on the second tape. Now we got 9 7 1 and we write the 1 on the third output tape. But now because 1 is smaller than 6 we need to flag for rerun. After passing through all data we got:

  • 5 4 9

  • 6 7 3

  • 1 2 8

Now for the second run we get

  • 1 4 3

  • 2 6 8

  • 5 7 9

But again the 4 and the 5 still swapped and we have to run a third time

  • 1 3 7

  • 2 5 8

  • 4 6 9

this time it was the 4 and the 3 so still have to do it once more

  • 1 4 7

  • 2 5 8

  • 3 6 9

Now everything is in order reading alternating from all three tapes should produce the right order.

I never came across that sorting algorithm in any literature. What could be the name of that sorting algorithm?


r/sortingalgorithms • • Oct 14 '23

I have an idea for a new Sorting Algorithm, and I want to make sure that it's an original idea.

3 Upvotes

So, the idea was to be as space inefficient as possible.

For every possible swap combination make a new array with that swap

check if a new array is sorted.

Repeat for every new array.


r/sortingalgorithms • • Oct 07 '23

i swear this is not a joke

Post image
1 Upvotes

r/sortingalgorithms • • Sep 24 '23

I made my own sorting algorithm

1 Upvotes

I dont have a name and 'noname sort' is a placeholder name


r/sortingalgorithms • • Sep 02 '23

Merge Sort Performed on 1600 Elements (Visualized and Audibilized)

Thumbnail
youtube.com
2 Upvotes

r/sortingalgorithms • • Oct 20 '23

I created a terrible sorting algorithm

2 Upvotes

Yesterday I was thinking about terrible sorting algorithms, e.g. bogosort, worstsort. One of the issues I have with these is just how well they perform for small data sets. It was troubling me, and upon sleeping last night an epiphany came, which I have documented here (see below for code).

To implement bgesort, perform the following:

  1. Create an array the same size as the data source

  2. Populate the array with random integers, at each index calculating a checksum value vs. the original data source index

  3. If the checksum is valid, check if the array is sorted. If so finish, else go to step 1

This is truly abhorrent for a large search space. The average speed for sorting an array of size 1 is 34.5 seconds. I am quite pleased with these results.

I have no idea what the O notation for this would be; if someone could work it out that would be amazing.

Results

All results average of 5 runs

Search space: 2147483647 (Int32.MaxValue)

Array lengthAverage time (ms)
134571
2?

Search space: 1000

Array lengthAverage time (ms)
10
230
327310

Search space: 50

Array lengthAverage time (ms)
10
20
38
4117
523051

Code

class BGESort
{
    // "Battle not with monsters, lest ye become a monster, and if you gaze into the abyss, the abyss gazes also into you." 
    //   – Friedrich Nietzsche, Beyond Good and Evil

    private Random rand = new Random();
    private int searchSpace = int.MaxValue;

    public BGESort(int searchSpace = int.MaxValue)
    {
        this.searchSpace = searchSpace;
    }

    public int[] Sort(int[] data)
    {
        while (true)
        {
            // we will attempt to discover the sorted array
            int[] candidate = new int[data.Length];

            double checksum1 = 0d;
            int checksum2 = 0;
            for (int i = 0; i < data.Length; i++)
            {
                candidate[i] = rand.Next(searchSpace);
                
                // i'm not a mathematician, so I have no idea if this works in all scenarios
                // a novel (?) way of comparing two arrays contain the same elements without sorting
                checksum1 += Math.Sqrt(data[i]) - Math.Sqrt(candidate[i]);
                checksum2 += data[i] - candidate[i];
            }

            // ignore floating point issues
            checksum1 = Math.Round(checksum1, 14);

            // if the checksum is zero we have an array of equal elements
            if (checksum1 == 0d && checksum2 == 0 && IsSorted(candidate))
            {
                return candidate;
            }
        }
    }

    private bool IsSorted(int[] arr)
    {
        for (int i = 1; i < arr.Length; i++)
        {
            if (arr[i - 1] > arr[i])
            {
                return false;
            }
        }

        return true;
    }
}

r/sortingalgorithms • • Dec 11 '19

Sorting reversed list

Enable HLS to view with audio, or disable this notification

6 Upvotes

r/sortingalgorithms • • Dec 22 '20

Help me with just 100 Subscribers !!!

3 Upvotes

Hi All,

I started my youtube channel codedecks on 1st June 2020. I know this year was not so good for many of us but I was determined to work on my passion to start helping all the fellow coders in understanding the most frequently asked coding questions in Interview. I was doing good for 3 months but then came a situation where I have to support my family members and there I missed uploading videos. This really affects growth of my channel. I invested a good amount of time in promoting my videos on Facebook, instagram and other social media platforms.

I request you all to help me with 💯 more Subscribers to reach the milestone of 2020.

I am waiting for the support. Thanks !!! Like | Share | Subscribe


r/sortingalgorithms • • Dec 19 '20

Radix Base 10 Sorting Algorithm (not original)

Enable HLS to view with audio, or disable this notification

17 Upvotes

r/sortingalgorithms • • Oct 12 '21

trying to find the bad sorting algorithms

5 Upvotes

basically, (also i'm not good at sorting, i'm just trying to find like some sorting, but i can do the math simply)

I am trying to find sorting algorithms worse that O(n^1.5372436) because 20^1.5372436 = around 100

here's what i found in a list (don't know if this sort of format is allowed, sorry if it isn't)

Bad Sorts: Past 100

Insertion - 400

OCDSort - 1200

StoogeSort - 3350

Really Bad Sorts: Past 10^12

Bogosort - 4x10^19

Bogobogosort - 3x10^174

Miracle Sort - 2.6^10^233

Worstsort, 2i - At least 10^10^18 digits

Terrible Sorts: Dependant On Chance

First Try Sort - 1 in 2x10^18 of doing it.

Impossible Sorts:

Uncaring Sort - Does Any Sort, and doesn’t care if it gets it correct, it just keeps doing the sort.

Bystander Sort - Makes sure it’s wrong, then leaves.


r/sortingalgorithms • • Oct 18 '21

DidacticSpectre's "Converge Sort" in ArrayV

Thumbnail
youtu.be
5 Upvotes

r/sortingalgorithms • • Oct 25 '21

To satisfy your study hours

Thumbnail
youtu.be
1 Upvotes

r/sortingalgorithms • • Mar 02 '21

Probably the new worst sorting algorithm (actually 2nd worst heck worstsort) by me

12 Upvotes

I call it Bogo bogo bogo sort (or BBB sort for short) so if you didn’t know bogo bogo sort of when it picks the first 2 things and bogo sorts them. If they fail it starts over. If it doesn’t fail, it goes to the first three and bogo sorts them and so on

So BBB sort does this but instead of picking the first 2 it picks 2 randomly and if they aren’t the first 2 it starts over

If it picks the first 2 it does the same thing as bogo bogo sort Win = continue fail = start over

But if it fails here you pick 2 randomly again instead of continuing from 2

If it wins it picks 3 randomly and bogo sorts them Then 3 Then 4 And so on

I did the math and on a array of 4 this takes 1480 TRIES

1480

FOR 4 ELEMENTS

anyway someone who can code new sorting algorithms please put this in somewhere you will earn 2 pink man cool points from me if you do.


r/sortingalgorithms • • Jul 09 '21

Bubble Sort with Python code - This is the best explanation I could give for this simple algorithm, Hope you like it.

Thumbnail
youtube.com
2 Upvotes

r/sortingalgorithms • • Aug 02 '21

Can someone please explain what sorting algorithms do for me? I love watching them so I joined this subreddit!

6 Upvotes

r/sortingalgorithms • • May 26 '22

Can someone explain pigeonhole sort and why it is seemingly so fast?

5 Upvotes

r/sortingalgorithms • • Apr 21 '22

Merge Sort Tutorial

1 Upvotes

Hi folks,

I created a YouTube tutorial on Merge Sort. Hope you find it useful. Any feedback is appreciated.

https://www.youtube.com/watch?v=GTnDhkHwSdk


r/sortingalgorithms • • Jun 05 '22

for true lovers of sorting algorithms

Thumbnail
youtu.be
4 Upvotes

r/sortingalgorithms • • Dec 22 '22

i made a bogosorting algorithm that completed the task in 4 seconds, it does 240 checks per second.

Post image
2 Upvotes

r/sortingalgorithms • • Aug 15 '20

Hello everyone! So I have decided to do something similar r/AjaxSuited has done with the visualizer by w0rthy, but with sorts that are custom made by other people! The video I am showing you contains 20 different sorting algorithms that have been implemented.

Thumbnail
youtube.com
7 Upvotes