10 Sorting Algorithms Visualized

Поделиться
HTML-код
  • Опубликовано: 8 сен 2024
  • GENERAL INFO:
    This is a showcase of the program made in the video here: • Coding a Simple Sort A...
    Source code available down below, but bare in mind it was my first time using Java Swing and so it is not great.
    There is a much better visualizer which can be found here: • 15 Sorting Algorithms ...
    EXPLANATION:
    There are 256 bars. Each bar has a height depending on the value of an integer array. For example, the bar on the far left has a height of the value of "array[0]" and the far right bar has the value of "array[255]".
    As the sort algorithm changes the array, the bars change height accordingly.
    Green bars are those most recently changed. They immediately go into a red bar, which gradually fades back to the default white colour.
    The sounds being played were made using Java's built in MIDI Channels and Synthesizer. A note is played each time a change to the array is made. The higher the pitch, the higher the value that was changed.
    =========
    DOWNLOAD: github.com/Hop...
    SOURCE CODE: github.com/Hop...
    =========
    RESOURCES:
    =========
    MUSIC USED:
    Ken Silverman - NEATSONG.kdm
    =========================================
    LINKS:
    GitHub: github.com/Hop...
    Discord Server: / discord
    Support me on Patreon: / hopson
    Follow me on Twitter: / hopson1997

Комментарии • 141

  • @homer076
    @homer076 6 лет назад +50

    0:02 Bubble sort
    0:46 Selection sort
    1:22 Cycle sort
    1:59 Stooge sort
    2:28 Quick sort
    3:09 Pancake sort
    3:56 Merge sort
    4:43 Insertion sort
    5:19 Heap sort
    6:02 Gnome sort

    • @KivySchool
      @KivySchool 5 лет назад +1

      Which one is fastest?

    • @johnheikens
      @johnheikens 5 лет назад +1

      @@KivySchool Quick sort is the simplest, and nearly the fastest, obviously.

  • @sayethwe8683
    @sayethwe8683 6 лет назад +225

    Quick sort just *begs* to be multi-threaded.

  • @Elias84777
    @Elias84777 5 лет назад +44

    CodeBullet gave you a shoutout.. It might be handy to come back! We'll appreciate it so much! :D

  • @Stray0
    @Stray0 6 лет назад +69

    Selection Sort and Cycle Sort have the best music imo

  • @YaYSilverWarrior
    @YaYSilverWarrior 6 лет назад +126

    Oh no! You forgot Bogo Sort! HOW COULD YOU?!

    • @nafinapkin5439
      @nafinapkin5439 6 лет назад +14

      4x speed ontop because this took longer than the expected lifespan of the universe!

    • @Cyamond
      @Cyamond 5 лет назад +4

      KeepDrive Plays
      it does bogosort, that's because each "shuffle" is actually 1 bogosort cycle

  • @opensauce04
    @opensauce04 5 лет назад +63

    2:27: my music teacher
    3:10:me

  • @jordanb722
    @jordanb722 6 лет назад +51

    It's funny how far superior some of the algorithms are to others. It would be nice to have a quick run up at the end to show just how much the sorting time differences are with the same delay.

    • @stewartzayat7526
      @stewartzayat7526 6 лет назад +10

      It also depends on what sort of data you are sorting. You should always pick the sorting algorithm with respect to your knowledge of your data.

    • @sharp14x
      @sharp14x 6 лет назад +1

      Some data is pre-sorted, hence that insertion sort would work best.

    • @Cyamond
      @Cyamond 5 лет назад

      SharpOB
      tim sort or any kind of block optimized merge sort would fare quite well too

  • @MrMusAddict
    @MrMusAddict 6 лет назад +19

    Definitely need a part 2! The Radix LSD sort is definitely the most interesting with sound, it would have been fantastic with the piano! Also, you should look into the Gravity sort. It would sound awesome too!

  • @Zekronz
    @Zekronz 6 лет назад +9

    Love how the merge sort works.

  • @pendergastj
    @pendergastj 6 лет назад +74

    No bogo sort? :(

  • @NevinWilliams71
    @NevinWilliams71 5 лет назад

    By far, the best sounding sorting visualizer I’ve come across.
    The code also compiled without a hitch, and runs well on my Mac... I wasn’t able to get Timo’s code running on it at all: I’m not very good at compiling, and he’s not touched the “sound of sorting” package for years.
    Cheers!

  • @TheDisastermanTv
    @TheDisastermanTv 6 лет назад +16

    Actually RadixSort would have been interesting too, maybe there will be a part 2 :D

  • @oldunused.emailmetogetmyne1997
    @oldunused.emailmetogetmyne1997 5 лет назад +1

    0:02 Bubble Sort: 14528 steps (2ms per step, 29.056 sec)
    0:46 Selection Sort: 255 steps (120ms per step, 30.6 sec)
    1:22 Cycle Sort: 254 steps (125ms per step, 31.75 sec)
    1:59 Stooge Sort: 16263 steps (5ms per step, 81.315 sec)
    2:28 Quick Sort: 1217 steps (30ms per step, 36.51 sec)
    3:09 Pancake Sort: 24099 steps (1ms per step, 24.099 sec)
    3:56 Merge Sort: 2048 steps (20ms per step, 40.96 sec)
    4:43 Insertion Sort: 17364 steps (1ms per step, 17.364 sec)
    5:19 Heap Sort: 1840 steps (20ms per step, 36.8 sec)
    6:02 Gnome Sort: 15979 steps (2ms per step, 31.958 sec)

    • @sander_bouwhuis
      @sander_bouwhuis 4 года назад

      Be warned that this is NOT a good video for determining the speed of the different algorithms. Memory usage and difference in cost between compares and swaps are more important. Sometimes you want to sort something which has a very high compare cost to it, while at other times memory is the bottleneck etc.

  • @Vextrove
    @Vextrove 6 лет назад +37

    I feel like the notes follow a major scale

    • @Hopsonn
      @Hopsonn  6 лет назад +20

      You have a good ear! They are all major :)

    • @Kitulous
      @Kitulous 6 лет назад +8

      I wish I knew music as good as you :( the only thing I got that this was piano :(

    • @threenplustwo9105
      @threenplustwo9105 6 лет назад +6

      Although the numbers can be very random indeed, so I could just as easily be dorian, phrygian, lydian, mixolydian, aeolian (minor) or locrian. Random notes makes it hard to pin down a tonal centre.

    • @opensauce04
      @opensauce04 5 лет назад +1

      @@Hopsonn :0

  • @Dezomm
    @Dezomm 6 лет назад

    Bubble sort may be awfully inefficient but I'll never stop loving it

    • @Hopsonn
      @Hopsonn  6 лет назад +1

      Thanks! I acknowledge another version of this in the video description :)

  • @das_9677
    @das_9677 6 лет назад +2

    I love the Merge Sort, it looks awesome :D

  • @duckmcfuddle7537
    @duckmcfuddle7537 5 лет назад

    I was looking through your old videos and found a project that really interests me, the Empire game. I downloaded it and love playing it over and over, and there are still so many places to go with it. An idea I had would be a "capitals" system, where the place that the colony spawns at would be a capital city and it being taken by another colony could deplete the original colony's strength. I don't know how popular it is with other people, and I know that the Empire video is like a year old, but I for one would love a part three.

  • @darkcisum3384
    @darkcisum3384 6 лет назад +1

    Selection sort sounds the best :)

  • @super4543
    @super4543 5 лет назад

    its very satisfying to look at.

  • @elfuturo4288
    @elfuturo4288 5 лет назад

    I came because I loved your work with making Minecraft in a week challenge. Great video!!

  • @joshuaisemperor
    @joshuaisemperor 5 лет назад +5

    I miss your videos man :(

  • @ryaningham5374
    @ryaningham5374 6 лет назад

    My A Level comp sci teacher showed us this while learning different sorting algorithms in python. I was so happy.

  • @darcipeeps22
    @darcipeeps22 6 лет назад +5

    Stresses me out but it’s damn cool

  • @lagomoof
    @lagomoof 6 лет назад

    The best O(n²) ones I've seen elsewhere but not here are cocktail shaker (bubble in both directions at once) and double selection (move both max and min elements each pass).

  • @pingupleb
    @pingupleb 5 лет назад +5

    miss ur vids man :(

  • @raphango
    @raphango 3 года назад +1

    Great! Any "best" algorithm you would reccomend for sorting an array of doubles?

    • @Hopsonn
      @Hopsonn  3 года назад

      Thanks!
      Selecting the optimal sorting algorithm should be based on how the data is accessed/used as opposed to what the array stores. For example, if you are going to need a constantly sorted array and will be inserting frequently, then insertion sort is the best bet; whereas if the data is usually unsorted then quick sort or merge sort are a good choice.

  • @fckyo333ujhjjkrrrr
    @fckyo333ujhjjkrrrr 6 лет назад +12

    Snek sort

  • @user-eh7hy2xn3w
    @user-eh7hy2xn3w 6 лет назад +4

    nice good vid

  • @Graeme_Lastname
    @Graeme_Lastname 6 лет назад

    Informative and interesting. Thanks.

  • @Kino-Imsureq
    @Kino-Imsureq 4 года назад

    please radix(lsd) sort, it's simple yet very interesting and also one of the fastest when it comes to gigantic arrays

  • @forxz1
    @forxz1 5 лет назад +1

    What resources did you use to explore opengl and sfml?

  • @dom4947
    @dom4947 6 лет назад

    This is so satisfying

  • @RADZIO895
    @RADZIO895 6 лет назад +3

    Bubble sort sounds like some Hans Zimmer music

  • @Vextrove
    @Vextrove 6 лет назад +3

    Nice

  • @ernest48914
    @ernest48914 6 лет назад

    I like how bubble sort is so shitty it is far behind with 15 times less delay and far less blocks than quicksort

  • @MaxPicAxe
    @MaxPicAxe 5 лет назад

    Great video!

  • @communistcat967
    @communistcat967 5 лет назад

    Do you plan on coming back? I just discovered your Channel and i found it amazing. (Sorry if late)

  • @isibboi
    @isibboi 6 лет назад

    This is basically a remake of sound of sorting, but with nicer sounds

    • @Hopsonn
      @Hopsonn  6 лет назад

      Yeah it is, I have linked to that in the description :)
      It looked cool so I wanted learn the sorting algorithms and try make my own version of it

  • @TumbleGamerTK
    @TumbleGamerTK 6 лет назад

    I like where it uses midi instead of beeps.

  • @minsin56
    @minsin56 5 лет назад +1

    will you ever make another video??

  • @mndtry
    @mndtry 6 лет назад

    Hi Hopson,
    I'm sorry if I'm off topic, but about sfml setting up CodeBlocks I have and answer, How do I export an sfml project to another pc?
    thanks.

  • @H0gwashing
    @H0gwashing 4 года назад

    if you listen closely, you can hear every midi that exists (and will exist) in this video

  • @cadencerobot
    @cadencerobot 5 лет назад

    Hello, you should make a turn base game similar to Civilization that would be cool

  • @gamermapper
    @gamermapper 5 лет назад

    Will you make another series about Minecraft in c++?

    • @gamermapper
      @gamermapper 5 лет назад

      @Maxi Minecraft in python in scratch

    • @gamermapper
      @gamermapper 5 лет назад

      @Maxi I don't know at all but Minecraft Bedrock edition is on c++

  • @pwouik9784
    @pwouik9784 5 лет назад

    Can you make things with compute shaders?

  • @FenerX
    @FenerX 5 лет назад

    Gnome sort? what about gnelf sort?

  • @AKABILASETOFICIAL
    @AKABILASETOFICIAL 6 лет назад

    Best Channel

  • @SephirothITM
    @SephirothITM 6 лет назад

    I hate how no one uses a binary search with insertion sort... I suppose it's only ever used as a bad example of list sorting but still, an obvious improvement.

    • @groszak1
      @groszak1 5 лет назад

      binary insertion sort is used in Timsort

  • @devonIsACoolGuy
    @devonIsACoolGuy 5 лет назад

    Some dude just sent this in the League chat, can't wait to feed

  • @Thepantino
    @Thepantino 6 лет назад

    Wow cool!

  • @purrleterian
    @purrleterian 5 лет назад

    I tried doing these in python with bubble sort. The algorithm was very easy, but I have no idea how to visualize it. Anyone can help me?

  • @joshuahodgson5989
    @joshuahodgson5989 6 лет назад

    Hi, i really want to get into coding and game development. Has nyone got any tips to get better?

  • @metalim
    @metalim 4 года назад

    2:27 what the HECK? that is NOT the quicksort. Common implementation goes from both ends.

    • @Hopsonn
      @Hopsonn  4 года назад

      Whoopsie poopsie

  • @OpticalDTV
    @OpticalDTV 5 лет назад +3

    whee are youuu

    • @Hopsonn
      @Hopsonn  5 лет назад +4

      hrrrrrrrrrrrrrrre

    • @JT-tz5hp
      @JT-tz5hp 5 лет назад

      @@Hopsonn Good to know youre still with us!

  • @zuzapinder5256
    @zuzapinder5256 5 лет назад

    What resources to learn java do you recommend?

  • @FalloutNewNarwhal
    @FalloutNewNarwhal 5 лет назад

    Pancake sort be like: YEEEEEEEEEEET

  • @TAP7a
    @TAP7a 6 лет назад

    How does the heap sort work?

  • @ahmidahmid9303
    @ahmidahmid9303 5 лет назад

    counting sort not in the list couse its a Hack in sorting very op

  • @RadioactivFly
    @RadioactivFly 5 лет назад

    Aww man you left out the radixes

  • @gamermapper
    @gamermapper 5 лет назад

    Can you make mario 64 in c++?

  • @ned431
    @ned431 5 лет назад

    can u make c++ tutorials. I think it will be great.

  • @LegatAbyssWalker
    @LegatAbyssWalker 5 лет назад

    Can you do a tutorial on OpenGL/C++?

  • @letitbegin1012
    @letitbegin1012 5 лет назад

    Just started the video, damn I hope theres bogo sort in this

  • @2007_Toyota_Corolla
    @2007_Toyota_Corolla 5 лет назад

    Oh he gone

  • @Julzaa
    @Julzaa 5 лет назад

    Selection sort huhuhu

  • @ayeshaawan6040
    @ayeshaawan6040 5 лет назад +3

    big oof notation are you even alive

  • @debblez
    @debblez 6 лет назад

    yyyyyyeeeeeeeeEEEEEEEEESSSSSSSSSSSSSSSSSSSSSSSS!!!!!!!!

  • @steamplayer2426
    @steamplayer2426 5 лет назад

    I suggest you make a game and post it online, even update it.

  • @vvv3636
    @vvv3636 5 лет назад

    Please, make random game in java

  • @username0705
    @username0705 6 лет назад

    3:09 Jesus Christ calm down.

  • @thearmyofiron
    @thearmyofiron 6 лет назад

    why suddenly use Swing ?

    • @Hopsonn
      @Hopsonn  6 лет назад

      As I said in my last video, it is because I have to use it for uni so i want to practice using it lol

    • @thearmyofiron
      @thearmyofiron 6 лет назад

      well, I haven't been following you a lot, so...welp, I didn't know.
      Too bad they didn't choose JavaFX

  • @seesoftware
    @seesoftware 6 лет назад

    why does it sound so tinny like you played it on a speaker and recorded it with a mic

    • @Hopsonn
      @Hopsonn  6 лет назад

      Honestly, no idea :(

  • @prizma_mama1838
    @prizma_mama1838 5 лет назад

    Do not watch this while your high

  • @ryanzwe
    @ryanzwe 5 лет назад

    Why did RUclips unsubscribe me from you

  • @MDTravisYT
    @MDTravisYT 6 лет назад

    MAH EEERZ

  • @fabripinta.
    @fabripinta. 5 лет назад +1

    F

  • @kratossparta8699
    @kratossparta8699 5 лет назад

    Code hex game in C

  • @O-J007
    @O-J007 5 лет назад +1

    Can you make fortnite in one week?

  • @YaBoiSweggie
    @YaBoiSweggie 5 лет назад

    Bro make big chungus pls😂😂😂

  • @d3spairs
    @d3spairs 5 лет назад

    You have my last name as your yt.

    • @Hopsonn
      @Hopsonn  5 лет назад

      It is also my last name lol

    • @d3spairs
      @d3spairs 5 лет назад

      Oh lol xX

  • @dustyhob0
    @dustyhob0 6 лет назад +8

    [unfunny comment]

    • @pritheebecareful6895
      @pritheebecareful6895 6 лет назад

      Your username and picture are perfect.

    • @grimtin10
      @grimtin10 6 лет назад +3

      [unfunny reply]

    • @WangleLine
      @WangleLine 5 лет назад

      [someone who doesn't get the comment and just begs to be wooshed]

  • @raeedibnzamanvintage7438
    @raeedibnzamanvintage7438 6 лет назад

    is c++ minecraft not a thing anymore? :(

  • @user-mo6tw8fj6h
    @user-mo6tw8fj6h 5 лет назад

    Russian sub please

  • @grimtin10
    @grimtin10 6 лет назад +3

    DON'T PUT DELAYS, it makes it look like the sorting algorithms are worse!

    • @Hopsonn
      @Hopsonn  6 лет назад +6

      I mean without delays, all them happen instantly lol
      Even with same delay, bubble sort etc would take several minutes while merge sort would take like 2s

    • @grimtin10
      @grimtin10 6 лет назад

      alright, but some of them, are EXTREME delays.

    • @Hopsonn
      @Hopsonn  6 лет назад +1

      @@grimtin10 for good reason lol

    • @grimtin10
      @grimtin10 6 лет назад

      alright then

  • @clusteringmiu
    @clusteringmiu 5 лет назад

    lol you are misguiding those who don't know programming XDD (jk

  • @nexovec
    @nexovec 4 года назад

    No radix sort lol noob

  • @aynurozdemir713
    @aynurozdemir713 5 лет назад

    Record more minecraft and became rich