Heaps and Heap Sort

A demonstration of heaps, heap sort, and a competition with merge-sort.
See here www.udiprod.com/heap-sort/ a more detailed discussion of the properties of heap sort.
Note that the procedures mentioned in the video, "sift-down", "heapify", and "sift-up", may be named differently in different descriptions of heapsort. The implementation is the same though.
Links:
---------
More details about this video: www.udiprod.com/heap-sort/
Previous matches:
Merge Sort vs Quick Sort: • Merge Sort vs Quick Sort
Quick Sort vs Bubble Sort: • Visualization of Quick...
Next match: • Insertion Sort vs Bubb...
Visit my homepage: www.udiprod.com

Пікірлер: 538

  • @jit_rs
    @jit_rs4 жыл бұрын

    It's fun how theese child-oriented videos actually explain heap implementation better than Wikipedia article. Keep up the good work!

  • @ilonachan

    @ilonachan

    4 жыл бұрын

    Well, Wikipedia isn't supposed to explain stuff for better understanding, it's supposed to just provide the information for everyone. That's why these tutorial-like videos are so important.

  • @therino9695

    @therino9695

    4 жыл бұрын

    Who said these were for children? These are for college students man!

  • @Lauren-ub6mj

    @Lauren-ub6mj

    3 жыл бұрын

    @The Rino im a kid, and somehow I still understand it.

  • @corvidconsumer

    @corvidconsumer

    3 жыл бұрын

    @@Lauren-ub6mj look at this genius guys

  • @unrelatedK

    @unrelatedK

    3 жыл бұрын

    Jason Zhang this is already simplified enough for kids

  • @wizardsuth
    @wizardsuth3 жыл бұрын

    The main advantages of heap sort are that it sorts elements in place and produces a valid partial result while the algorithm is still running. With most other algorithms you don't get any results until they're finished or nearly finished. For instance merge sort produces no results until the start of the final merge. Heap sort starts producing results right after heapify is done, albeit in reverse order. Another advantage is that heap sort doesn't require a lot of metadata. With merge sort you must keep track of all the lists to be merged, typically using a stack. With heap sort you just need a reference to the element being sifted up or down. The sift operations use tail recursion, which means they can be done iteratively. It's not really fair to compare heap and merge with only ten elements. Try it with about 10,000 and see how they compare.

  • @kienthanhle6230

    @kienthanhle6230

    2 жыл бұрын

    There're an inaccuracy in your statement tho. If heap sort is producing results in reverse order, just use min heap.

  • @Bubu567

    @Bubu567

    2 жыл бұрын

    "reverse order" In a order. Not 'reverse order'. The order it produces results in may or may not be the correct 'side' of the sort. It depends on if it's told to sort ascending or descending. Even then, it can invert your choice and then return the list backwards to you when you ask for it.

  • @Tasarran

    @Tasarran

    Жыл бұрын

    I find a heap most useful specifically in pathfinding. Don't actually sort it, just maintain the heap properties when all you really need to know is what is the biggest (or in some cases smallest) out of a collection, like when selecting which node to expand next. You don't care about how the rest of the list is sorted, as long as you van get the biggest one. You can get it in one operation, then run a sift-up one time, which will take something like square root of N operations...

  • @kienthanhle6230

    @kienthanhle6230

    Жыл бұрын

    @@Tasarran nah it's log n, which is way less than sqrt N

  • @GTD_GameTilDead

    @GTD_GameTilDead

    10 ай бұрын

    How are they gonna fit that many balls, let alone make time to sort them?

  • @rosebuster
    @rosebuster7 жыл бұрын

    Heap Sort may not be ideal when sorting is all you want to do, but this whole idea of a heap becomes invaluable when you need a data structure that allows you to always take out the smallest element quickly, but also be able to quickly modify the data in the heap in between. And often in solving some more advanced problem this is exactly what you need to do it efficiently.

  • @cyndie26

    @cyndie26

    6 жыл бұрын

    Maks Rosebuster Heapsort only requires one array to be used, so it doesn't take up as much memory as mergesort. Even with an array of a million objects, heapsort only takes about a second to sort everything. (I know because I just had to write a heapsort algorithm for a university project and the I remember hearing that the professor wanted us to sort that large of an array in under 30 seconds.)

  • @elitezinc2758

    @elitezinc2758

    6 жыл бұрын

    You gave an explanation of priority queue with implementation, nice

  • @KnakuanaRka

    @KnakuanaRka

    4 жыл бұрын

    Yeah, in that implementation, it’s often called a priority queue, because you can freely insert objects, and easily look at and remove the one with highest priority (imagine a hospital waiting room, where the people with worse injuries get taken in first).

  • @ohno-wi1vb

    @ohno-wi1vb

    4 жыл бұрын

    K1naku5ana3R1ka very interesting

  • @tabularasa0606
    @tabularasa06063 жыл бұрын

    Heap sort is still my favorite, it's just a beautiful algorithm that works perfectly when you have to sort extremely large lists.

  • @bitonic589

    @bitonic589

    10 ай бұрын

    Pigeonhole sort:

  • @gm_construct_13_betaexplor38

    @gm_construct_13_betaexplor38

    9 ай бұрын

    @@bitonic589pigeonhole is only good if every element is unique

  • @official-obama

    @official-obama

    4 ай бұрын

    @@bitonic589 imagine sorting floats with that

  • @bitonic589

    @bitonic589

    4 ай бұрын

    @@official-obama Treat the floats as integers

  • @Blazewoods
    @Blazewoods4 жыл бұрын

    Different sorting compilations started showing up in my recommended, and I started watching them, confused on what they were, and now these have shown up. I’m not disappointed, just confused.

  • @cpufreak101
    @cpufreak1018 жыл бұрын

    you seriously need to get those robots a set of glasses, then again, it'd prevent them from taking over without them

  • @groszak1

    @groszak1

    6 жыл бұрын

    but then it won't be realistic, computers can't just analyze every item simultaneously

  • @nolanjshettle

    @nolanjshettle

    5 жыл бұрын

    groszak1 actually a fairly simple digital logic circuit can be made to sort/compare several (less than 10) objects at once. An entirely new set of sorting algorithms would need to be implemented to take advantage of this but I wouldn't be surprised if you could get an order of magnitude improvement in sorting speed over a lucky quicksort. The problem with doing this is that sorting isn't done very often. You may ask your computer to sort things occasionally but it's not happening 60 times a second, once for each frame/update in a video game for example so doesn't need a drastic speed up.

  • @FplusETVChannel

    @FplusETVChannel

    5 жыл бұрын

    groszak1 computers use mostly quick sort

  • @coolmanjack1995

    @coolmanjack1995

    5 жыл бұрын

    @@groszak1 I believe it was a joke

  • @NyscanRohid

    @NyscanRohid

    4 жыл бұрын

    The robots with glasses sorting algorithm is called radix sort.

  • @aidanmaley9826
    @aidanmaley98267 жыл бұрын

    It's 1AM I have school tomorrow I need to finish my homework but I'm looking at CGI robots demonstrating sorting algorithms

  • @papinkelman7695

    @papinkelman7695

    7 жыл бұрын

    Large Moose realy? cgi robots, not real ones?

  • @aidanmaley9826

    @aidanmaley9826

    7 жыл бұрын

    Pa Pinkelman Really* And I meant that the little CGI characters are representative of robots. So... CGI robots.

  • @papinkelman7695

    @papinkelman7695

    7 жыл бұрын

    I know what you meant... I rea ll y do.

  • @regen-Q

    @regen-Q

    5 жыл бұрын

    Plot twist: the homework IS about sorting algorithms

  • @KnakuanaRka

    @KnakuanaRka

    4 жыл бұрын

    Hey, my homework is about heap sort, so what’s the problem?

  • @simzhou
    @simzhou3 жыл бұрын

    00:07 Intro to Heap/Heap Sort 02:37 Building the Heap in the first place (Heapify) 03:33 How is new elements added into a Heap 04:07 Heap Sort V.S Merge Sort Excellent Work! I felt like I haven't grown up yet! lol

  • @AndreaForlani

    @AndreaForlani

    2 жыл бұрын

    Thank you, Yuyuko-sama

  • @Heligoland360
    @Heligoland3607 жыл бұрын

    I would like to see a Radix sort video.

  • @pussinbootsisawesome

    @pussinbootsisawesome

    7 жыл бұрын

    Rohan Zener kinda like sorting quarters then sorting again and again until it is sorted. idk

  • @VivekGawande1

    @VivekGawande1

    7 жыл бұрын

    Rohan Zener Radix sort sorts the number by the following procedure: First it sorts the elements based on units place Next it sorts the elements based on tens place And so on...

  • @Snagabott

    @Snagabott

    7 жыл бұрын

    Radix rocks... but not on colored balls. Which I assume was the point.

  • @MrHatoi

    @MrHatoi

    6 жыл бұрын

    Radix only works on integers though, so it's not going to fit the colored ball example.

  • @gordn_ramsi

    @gordn_ramsi

    6 жыл бұрын

    You can just put numbers on the balls, can't you?

  • @codenamelambda
    @codenamelambda9 жыл бұрын

    I really like your videos about sorting. They are great visualized, and it is the first time for me understanding Heap Sort and Quick Sort XD

  • @udiprod

    @udiprod

    9 жыл бұрын

    CodenameLambda Great :) Thanks!

  • @codenamelambda

    @codenamelambda

    9 жыл бұрын

    udiprod Nothing to thank for, because I have to thank you ;) So: Thank you!

  • @jamesyeoman794

    @jamesyeoman794

    7 жыл бұрын

    As an A-Level Computer Science student, I agree CodenameLambda (HL3 confirmed?). It is a lot easier to understand an algorithm when you have a visualization of what it's doing.

  • @mixup2216
    @mixup22165 жыл бұрын

    I like the screens in front of their table. It makes it much easier to understand.

  • @masonhunter2748

    @masonhunter2748

    3 жыл бұрын

    Bro that burger look like a noob subreddit icon

  • @epsilonthedragon1249
    @epsilonthedragon12497 жыл бұрын

    "Each ball is brighter than its children." Looks like those kids need some homeschooling.

  • @zeusrulez

    @zeusrulez

    5 жыл бұрын

    That One Random Gamer there’s a lot of corruption in the ball education system- money over mind, it’s a depressing world out there for modern balls

  • @mapelaanjakoodaansuomeksi3432

    @mapelaanjakoodaansuomeksi3432

    5 жыл бұрын

    @@zeusrulez Yeah, many balls have been popping themselves with needles. In Memoriam of Bright Maroon-Black.

  • @suwinkhamchaiwong8382

    @suwinkhamchaiwong8382

    5 жыл бұрын

    xD

  • @taureon_

    @taureon_

    5 жыл бұрын

    @@zeusrulez this comment is too underapprechiated

  • @DNXTMaster

    @DNXTMaster

    4 жыл бұрын

    I'm the one dumbass thinking this was an interracial relationships joke

  • @leonardoantonio216
    @leonardoantonio2165 жыл бұрын

    I love how the Merge Bot had a face like "Can I leave now?" Or "Can I have my cookie now?"

  • @KristabelHilton

    @KristabelHilton

    3 жыл бұрын

    I felt sorry for the Heap Sort robot still working hard while the Merge Sort robot was just standing there. I imagine merge sort robot tapping his foot impatiently!

  • @Axacqk
    @Axacqk4 жыл бұрын

    I just came from the halting problem video, amazed how great your physical world analogies are. The short-sighted robot that can only look closely at two balls at a time in order to compare them is another gem!

  • @beetlemush768
    @beetlemush7684 жыл бұрын

    I have no idea what brought me here but this seems to be a good way to spend my quarantine

  • @tehrackoon2021
    @tehrackoon20216 жыл бұрын

    So are these little robots actually in my computer?

  • @GiornoGiovannaGangstar

    @GiornoGiovannaGangstar

    6 жыл бұрын

    yes it is my dude

  • @neoxus30

    @neoxus30

    6 жыл бұрын

    That's bullshit, but i believe it)

  • @mapelaanjakoodaansuomeksi3432

    @mapelaanjakoodaansuomeksi3432

    5 жыл бұрын

    @@cyllum8627 r/wooosh

  • @guidomarrone9562

    @guidomarrone9562

    5 жыл бұрын

    They are in your blood. They carry your oxygen.

  • @mapelaanjakoodaansuomeksi3432

    @mapelaanjakoodaansuomeksi3432

    5 жыл бұрын

    @@guidomarrone9562 **they sort your oxygen

  • @dominiqueveilleux2802
    @dominiqueveilleux28027 жыл бұрын

    I really would like to see more of those videos about sorting. I need to find a quick way to sort my books in alphabetical order.

  • @lucidmlem

    @lucidmlem

    2 жыл бұрын

    Quick sort could be good Take a book from the middle, and put every book that comes before that before it, and every book that comes after that after it. Repeat it with your groups, until you have groups so small, they could be sorted with a different sort.

  • @HallidayASR
    @HallidayASR7 жыл бұрын

    Even before the match started I knew Heap sort would lose :( It seems like a bad sort

  • @TomBertalan

    @TomBertalan

    6 жыл бұрын

    Spoilers, man.

  • @trangium

    @trangium

    6 жыл бұрын

    It's better than bubble sort, though.

  • @setsunaes

    @setsunaes

    5 жыл бұрын

    It has its uses, like when speed is not that important but memory usage is a big concern.

  • @user-jc2lz6jb2e

    @user-jc2lz6jb2e

    5 жыл бұрын

    Heap sort is not bad; it's O(nlog(n)) just like Merge sort.

  • @AndreUrzua1

    @AndreUrzua1

    5 жыл бұрын

    I created both algorithms to test the time it takes for each to sort a vector, and actually heapSort was actually faster than MergeSort... like twice as fast. I think that making copys of the initial vector is a heavy task and makes HeapSort better or something I don't know, but numbers are really consistent

  • @prysthaea7735
    @prysthaea77352 жыл бұрын

    This series is a gem

  • @dlwatib
    @dlwatib9 жыл бұрын

    Do smoothsort. It's along the same lines as heapsort, but does things kinda backwards so that it doesn't have to move any data if it's already sorted.

  • @FloodlightGamingReal
    @FloodlightGamingReal Жыл бұрын

    I remember watching visual versions of these (the ones that make sound that sounds like if edm music made an incest baby with a 4 year old 'composing' music) and being so confused about what was going on, and your videos make things so much easier to understand. Thank you for making these, keep up the good work!

  • @a.human.
    @a.human.2 жыл бұрын

    One of the best, visually well explained educational videos my eyes have ever watched.

  • @TimForTheWin12
    @TimForTheWin128 жыл бұрын

    It might be more efficient for someone to design better eyes for your robots :P

  • @noyz-anything

    @noyz-anything

    6 жыл бұрын

    this is not possible, as they are looking into the souls of the balls

  • @DEFCON1GAMRS

    @DEFCON1GAMRS

    6 жыл бұрын

    That’s right, skin may be darker but the soul is blacker. (Racism humor intended, no harm intended, im sure i wasnt the only one that thought this.)

  • @johnrose411

    @johnrose411

    6 жыл бұрын

    DEFCON1GAMRS yeah me too

  • @GiornoGiovannaGangstar

    @GiornoGiovannaGangstar

    6 жыл бұрын

    the good Boyes go at the front,the bad Boyes go to the back

  • @YaboiMuggy

    @YaboiMuggy

    5 жыл бұрын

    the "short sighted robot" is just an metaphor for the way the algorithms are programmed.

  • @ForTheOmnissiah
    @ForTheOmnissiah2 жыл бұрын

    I think it would be more fair to also show a heapsort vs mergesort when the heapsort already has a heap structure. Both of these algorithms have O(n log n) time complexity, assuming the heapsort is executing on an already existing heap. Heaps have the advantage that extracting the min (or max for a maxheap) element is a consistent O(log n) time complexity, which is fantastic speed. This has a very high amount of use cases.

  • @johncochran8497
    @johncochran84976 жыл бұрын

    One major advantage to heapsort that's not addressed here. If you have more elements to sort than will fit into memory, you need to resort to an external merge sort. And the number of passes that the merge sort requires is dependent upon the number of runs (sorted sequences) that are already created. Assuming you can store N items in memory, the technique is to read in N items, sort them, then write out that run and repeat until you've created the initial set of runs. So each run is N items long. However, in heapsort, you read in N items, write out the lowest item and then read in the next item. If it's greater than the item just written, place the newly read item into the heap and continue. If it's less than the item just written, reduce the heap by 1 element and save the newly read item into storage. Result is that on average, using heapsort, the initial length of each run is 2N, not N. So you have about half as many runs to process with mergesort. So it runs faster.

  • @sevarbg83
    @sevarbg839 жыл бұрын

    Now this is how all programming tutorials must be made! Excellent! In this way they can be understood by small kids.

  • @maksimkiselev255
    @maksimkiselev2556 жыл бұрын

    One of the best and simpliest explanations ever.

  • @niemiec2601
    @niemiec26014 жыл бұрын

    Thanks! I Realy Struggled with Heap Sort. So This Helps ALOT.

  • @SarenArterius
    @SarenArterius8 жыл бұрын

    My teacher is now playing this in the Data Structure lesson! :)

  • @feritperliare2890

    @feritperliare2890

    2 жыл бұрын

    Kinda sad though cause this is actually kind of a poor example of heap sort considering usually it's faster than merge sort

  • @atprra
    @atprra4 жыл бұрын

    I love all of your videos. They are the best! Keep up the good work

  • @duman.naz.a
    @duman.naz.a3 жыл бұрын

    I dont learn these in school, my main language isnt even English. But these, oh boi these are hella worth the watch

  • @dzarthedemon4855
    @dzarthedemon48553 жыл бұрын

    Not gonna lie, this actually kinda fun to watch.

  • @wendyhau7644
    @wendyhau76448 жыл бұрын

    Love these videos! Would be great if you could do some more. So much help. Thank you!!

  • @bitrunner8759
    @bitrunner87593 жыл бұрын

    i love seeing the winner robot just sit there waiting like *can i go home now*

  • @TwoAwesomePeopleTAP
    @TwoAwesomePeopleTAP2 жыл бұрын

    …is it weird I wish I had the money to commission this channel to animate explanations of more and more sorts in this style? The graphics remind me of the old Kutoka Interactive edutainment games I used to play as a kid, like Mia Mouse. It feels like I’m hear to learn without judgement, and yet with little bits of humor thrown in. Not to mention all the sounds are soothing.

  • @ProfessionalEngg
    @ProfessionalEngg7 жыл бұрын

    I can see the effort in making this video. Appreciate it. Thanks.

  • @kishw0nky
    @kishw0nky9 жыл бұрын

    great video, i enjoy the robot animations, esp the battle at the end to help actualize sorting algorithms. Helps some of us visual-programmers understand what's going on. I get sick of algorithms easily, this helps :)

  • @Kram1032
    @Kram10329 жыл бұрын

    always nice to see one of these

  • @BlazerMinecrafter
    @BlazerMinecrafter2 жыл бұрын

    This is an excellent visualization of trees and heap sort. Damn.

  • @ShaanNotShawn
    @ShaanNotShawn9 жыл бұрын

    These animations are amazing. Thank you!

  • @bullseyecg3501
    @bullseyecg35013 жыл бұрын

    i dont understand why anyone would need this information but its cool and i like it

  • @homqua9613
    @homqua961316 күн бұрын

    The explain is so brief and clear, thanks so much.

  • @sonxuannguyen1207
    @sonxuannguyen12074 жыл бұрын

    I think u should put numbers that represent the brightness on the ball, because numbers will help very much in illustrating as well as understanding the algorithms

  • @michaelwolfe7970
    @michaelwolfe7970 Жыл бұрын

    this video makes the concept of heapsort so obvious. honestly, i don't know why I was even wasting my time trying to decipher that thick, confusing textbook anymore.

  • @enclave2k1
    @enclave2k17 жыл бұрын

    Oh my!! I love your videos, you need to make more!!!

  • @nadie-qm8rq
    @nadie-qm8rq2 жыл бұрын

    I love these videos, but I wish youtube had recommended them to me two years ago when I was taking structure and algorithms class.... but is good to remember now, since I forgot it all

  • @CARLOSINTERSIOASOCIA
    @CARLOSINTERSIOASOCIA9 жыл бұрын

    love your videos, please keep doing them :)

  • @udiprod

    @udiprod

    9 жыл бұрын

    Thanks!

  • @rhythmscorpio5692
    @rhythmscorpio56928 жыл бұрын

    Nice ... I have learnt Quick Sort and Heap Sort for 2 years and used it to solve many exercises in my school but in that time, I just learnt by heart (because I can't understand them) Until now, I can understand these algorithms ... thank you so much !!! Love you :* =))) ...... And the robots are so cute :v =)))

  • @rosebuster

    @rosebuster

    7 жыл бұрын

    How can you learn these algorithms without understanding what they do? You memorize the code or something? Like the exact things you have to type? I think when most people program something, they know what they want the program to do and then they construct the code doing exactly that.

  • @HalfEye79
    @HalfEye797 жыл бұрын

    I would like to see a comparison between Bubble Sort and Gnome Sort. BTW: When I programm something to use gnome sort, I add a variable, at which number the algorithm was, when it starts to compare to the start. Then, when it's ready, it can go just to this index and don't compare up to the turning point.

  • @IAMHAPPY5290
    @IAMHAPPY52902 жыл бұрын

    Very interesting video. I cant seem to wrap my head around the heap sorting thing but hey it was fun to try

  • @hisho2255
    @hisho22559 жыл бұрын

    I cant wait to see your next vid keep up the great work

  • @udiprod

    @udiprod

    9 жыл бұрын

    Jonathan Turner Thanks! :)

  • @antonnym214
    @antonnym2143 жыл бұрын

    Your robot animations are adorable!

  • @damnstupidoldidiot8776
    @damnstupidoldidiot87765 жыл бұрын

    Thanks, now I can implement heap sort.

  • @franciscogallegosalido1402
    @franciscogallegosalido14028 жыл бұрын

    I don't think this would be a really good idea (since the algorithm is just too difficult to understand), but Tim sort looks like a really popular algorithm nowadays (Python and Open JDK implement it). There's also some stupid algorithms like Slowsort or one I implemented called "Permutation sort", which checks every single permutation of the array until it finds the ordered one. Anyway, I really like how easy to understand are your videos!

  • @traugdor

    @traugdor

    7 жыл бұрын

    Permutation Sort is another name for Bogo Sort.

  • @52flyingbicycles
    @52flyingbicycles6 жыл бұрын

    heapify: one of my new favorite words

  • @razerage1
    @razerage16 жыл бұрын

    I don't know how these sorting algorithm videos could be useful to me someday..

  • @andreiiaz2097

    @andreiiaz2097

    3 жыл бұрын

    Well, you understand how each sorting algoritm works and which one is better

  • @masonmunkey6136

    @masonmunkey6136

    3 жыл бұрын

    If you ever get into programing

  • @chokkko
    @chokkko2 жыл бұрын

    I like the fact that I don't fucking know what this channel is for, but still love it

  • @typhoon1575

    @typhoon1575

    Жыл бұрын

    It's all visual analogy for computer coding systems.

  • @AwesomeMinecraftersakuraodomMC
    @AwesomeMinecraftersakuraodomMC7 жыл бұрын

    Can you do a video on gravity/bread sort? I don't understand it at all and I love your visualizations.

  • @want-diversecontent3887

    @want-diversecontent3887

    6 жыл бұрын

    sakurawolfie It just gravitates units, it can't be visualised here.

  • @halfnwhole751

    @halfnwhole751

    5 жыл бұрын

    Gravity Sort just makes the darker ball heavier and vice versa and then pushes them to fall of the shelf And bread sort just sorts bread not balls

  • @windowsxseven

    @windowsxseven

    2 жыл бұрын

    Maybe it's for the better that you don't put your dirty little hands on gravity sort. Clearly if you need a video to understand it, it's not meant for you. Stick to bubble sort, peon.

  • @reissner1967
    @reissner19675 жыл бұрын

    I like that you made the ROBOT EYES MOVE, look at each ball when they are brought to the robot’s face. :) I noticed that. :)

  • @jabre7761
    @jabre77614 жыл бұрын

    Do gravity sort That would be quite a show

  • @mcvibing2785

    @mcvibing2785

    2 жыл бұрын

    "SORT SESAME" And then they change color

  • @Palfurniture
    @Palfurniture8 жыл бұрын

    Very awesome videos, thank you.

  • @davidcotand6051
    @davidcotand60519 жыл бұрын

    Finally! A new video!

  • @XaxtonRevolution2
    @XaxtonRevolution22 жыл бұрын

    Could you please specify the decision tree which is being used in heapify? I can't figure out from how the order of which ball to look at next is being determined. And when you say the lowest ball do you mean the one at the bottom or the darkest one?

  • @maglev957
    @maglev9573 жыл бұрын

    I need to see a tournament of every sorting algorithm in this style

  • @nasifali2235
    @nasifali22357 жыл бұрын

    Wow what a way to explain !!! Thank you !!!

  • @davidjames1684
    @davidjames16845 жыл бұрын

    It would be interesting to "hand trace" a small manageable example like this and count the number of swaps using the traditional method (of just "popping" the top element), vs. my idea of popping the top 2 elements (the root and the brighter of the children in this example). I am thinking if the number of swaps is less using my method, it is a valid improvement and should make runtime on a more substantial tree (such as 1 million random numbers), get sorted faster with "double pop" heapsort. The idea is to get the known 2 brightest balls out of the heap quicker (than 1 at a time).

  • @SyntekkTeam
    @SyntekkTeam9 жыл бұрын

    Great video. This gave me a great review of heaps. Just out of curiosity when animating the robots do you do all the movements individually or do you have a way of automating it?

  • @udiprod

    @udiprod

    9 жыл бұрын

    Thanks! Yes, it's automated using a script.

  • @sleetskate

    @sleetskate

    9 жыл бұрын

    udiprod can you do selection sort vs merge sort next?

  • @udiprod

    @udiprod

    9 жыл бұрын

    ***** Thanks for the suggestion. I think visualizing selection sort using robots sorting would like quite similar to bubble sort, which I already had done. Bubble sort makes more swaps, but the basic idea of searching for the min (or max) in the unsorted part of the list would look very similar.

  • @sleetskate

    @sleetskate

    9 жыл бұрын

    try radix LSD then, i love these videos

  • @friendhaus1858
    @friendhaus18584 жыл бұрын

    "Now the tree is in an illegal state" Ok who's been planting trees in israel

  • @tsaed.9170

    @tsaed.9170

    3 жыл бұрын

    😂😂 dafuck

  • @kornsuwin

    @kornsuwin

    3 жыл бұрын

    this is great

  • @TheGeeMaster1337

    @TheGeeMaster1337

    3 жыл бұрын

    Other trees

  • @Tuxfanturnip

    @Tuxfanturnip

    3 жыл бұрын

    KKL

  • @lesleyzore987

    @lesleyzore987

    3 жыл бұрын

    Now this is genius.

  • @dw1664
    @dw16649 жыл бұрын

    Brilliant video.

  • @Luigion7
    @Luigion72 жыл бұрын

    0:42 "Now the tree is *_in an illegal state."_* -had me rolling-

  • @Pyramid132420
    @Pyramid1324208 жыл бұрын

    Will you be doing all of the common basic/advanced sorts?

  • @udiprod

    @udiprod

    8 жыл бұрын

    +Pyramid132420 I plan to do more of them, among other things.

  • @udiprod

    @udiprod

    8 жыл бұрын

    The next video will be about physics again, and will be published quite soon hopefully. I promise to do another sorting video afterwards. Thanks for the suggestion. May I ask why you are particularly interested in bogosort?

  • @maxikiosco8192

    @maxikiosco8192

    5 жыл бұрын

    udiprod I'm actually really interested in the efficiency of bogosort vs bozosort

  • @yahoo5726
    @yahoo5726 Жыл бұрын

    I like how they all have different tables

  • @cameodamaneo
    @cameodamaneo7 жыл бұрын

    I found some demonstrations regarding an algorithm called "gravity sort" but I can't seem to find any video that gives an explanation. Would you be able to point me in the direction of some resources that could explain it?

  • @hkplaymad
    @hkplaymad9 жыл бұрын

    That was amazing!

  • @erostanatos2975

    @erostanatos2975

    4 жыл бұрын

    amazinnnngg

  • @florianmayr39
    @florianmayr393 жыл бұрын

    Through this video I understood the concept of heap sort. (I am a informatics student)

  • @sidharthbansal8975
    @sidharthbansal89756 жыл бұрын

    i really like your videos

  • @davidjames1684
    @davidjames16845 жыл бұрын

    These type of sorts are mainly for educational purposes only since counting sort seems to be very fast for a reasonable number of possible values and is much simpler to implement. I tried implementing heapsort but I got myself into a heap of trouble.

  • @Galaxy-jy6qb
    @Galaxy-jy6qb7 жыл бұрын

    Can you do Cocktail Shaker sort vs. Merge sort, Quick sort and Heap sort?

  • @SyuAsyou
    @SyuAsyou7 жыл бұрын

    堆積排序法:將排列按亮度排成樹狀圖(堆積化),取得最亮後從底部取一顆球置於頂部。頂部與支部比較,和最亮的交換,逐一比較直至底部。以上步驟反覆進行直至取完全部的球。 堆積排序法因更多次的比較而不如合併排序法快速。合併排序法需要額外的整排空間,而堆積排序法只需要較少的空間。 快速排序法平均而言比合併排序法和堆積排序法都要快,但遇到最槽情況時會更慢,此時堆積排序法會比較快。 當空間不足且不允許忽快忽慢時,堆積排序法較優。

  • @allergictosanity
    @allergictosanity6 жыл бұрын

    Can you do a video on selection sort?

  • @mattthegamerhongkong6948
    @mattthegamerhongkong69484 жыл бұрын

    Iirc heap sort is like this: Suppose we have an array of data, from 0x0000 to 0xFFFF, each value is represented by one and only one datum. Separate the data into heaps of size 0x100, i.e. 0x0000 to 0x00FF; 0x0100 to 0x01FF; 0x0200 to 0x02FF, etc. Check to see that all data is placed into their heaps; then assign a heap number to each heap. Now one heap can be treated as a single datum, i.e. heaps 0x0 to 0x100. Sort the heaps using another technique, like QuickSort. Now the data is nearly sorted, use multithreading to sort multiple heaps at once. Here I'll use QuickSort again. Since the heaps are sorted, i.e. the largest element in the last heap is no larger than the smallest element in the next, we need not check if the entire array is in order after we sort each heap, for it is by definition always true after we sort each heap separately In this sample size of 65536, we only need to compare the whole array against a number once, which is faster than the method shown

  • @salsamancer
    @salsamancer6 жыл бұрын

    Is the heap sort faster if you start out with an existing heap and need to sort it?

  • @feilbruno1
    @feilbruno18 жыл бұрын

    great video!

  • @yash1152
    @yash1152 Жыл бұрын

    this ia actually useful. thanks for it.

  • @Geoxor
    @Geoxor9 жыл бұрын

    4:14 im just curious if you guys make the animation faster so it does it faster, is that the case?, it doesnt look like it is faster though...

  • @udiprod

    @udiprod

    9 жыл бұрын

    Which animation seem faster to you? They're all the same. If you ask about merge sort vs heap sort then you can check the comparisons count. They advance at a similar rate.

  • @Geoxor

    @Geoxor

    9 жыл бұрын

    udiprod The yellow one, thanks for the answear

  • @Marksman560
    @Marksman5609 жыл бұрын

    This video distorts the value of Heap Sort: Heaps/Heap sort is nice when you have big sets (of colored marbles). And when marbles are added (This keeps previous sorted 'info', without the need for new comparisons/recalculations)

  • @udiprod

    @udiprod

    9 жыл бұрын

    Marksman560 You are talking about heaps in general. Heap-sort is a sorting algorithm that uses a heap, but it can't handle new marbles. It has to restart sorting from scratch. Btw, I did mention heap sort has some benefits in the accompanying link zutopedia.com/hs_vs_ms.html And you are right, perhaps it's worth a mention that heaps by themselves have some great benefits of their own.

  • @anastasiadunbar5246
    @anastasiadunbar52468 жыл бұрын

    When will you make more videos? Your videos are interesting.

  • @udiprod

    @udiprod

    8 жыл бұрын

    Anastasia Dunbar Thanks a lot :) I hope to finish a new video about physics in 2-3 months. I hope you'll find it interesting too.

  • @kloppie5
    @kloppie59 жыл бұрын

    Will you do radix sort in the future?

  • @udiprod

    @udiprod

    9 жыл бұрын

    I might. It's an interesting algorithm. It would have to look very different than the current way I visualize sorting algorithms, since radix sort relies on digits of numbers, so sorting by colors won't work well.

  • @want-diversecontent3887

    @want-diversecontent3887

    6 жыл бұрын

    udiprod Shell sort or comb sort?

  • @progamerzzz1237
    @progamerzzz12373 жыл бұрын

    Why did u stopped making videos. They are so good

  • @acatnamedmickey
    @acatnamedmickey4 жыл бұрын

    i am never going to use this information, but i'm still watching it

  • @copperII_
    @copperII_2 жыл бұрын

    Implementing Heap Sort is kinda a good way to understand trees

  • @anubhavgupta4595
    @anubhavgupta45957 жыл бұрын

    can you pls do Timsort or introsort or any hybrid sorting algorithm

  • @vinceguemat3751
    @vinceguemat37517 жыл бұрын

    why do we use heap sort if merge sort is quicker ?

  • @PheloSaad
    @PheloSaad4 жыл бұрын

    Can you do Selection Sort? :)

  • @Psyk0h
    @Psyk0h7 жыл бұрын

    I never thought I be so into a series about watching two robots see who can sort faster I think I need to go to bed now...

  • @elijah4840
    @elijah48403 жыл бұрын

    Fantastic!!

  • @pushbutton8548
    @pushbutton85488 жыл бұрын

    What's the worst non-randomised sorting algorithm that does no redundant statements?

  • @Skrelpoid

    @Skrelpoid

    8 жыл бұрын

    probably bubble sort

  • @massimookissed1023

    @massimookissed1023

    8 жыл бұрын

    I'd agree with Dustin.

  • @groszak1

    @groszak1

    6 жыл бұрын

    do you count stooge sort as doing no redundant statements?

  • @want-diversecontent3887
    @want-diversecontent38877 жыл бұрын

    Places: 1. Merge Sort (25, 23) 2. Heap Sort (39) 3. Quick Sort (21, 33) 4. Bubble Sort (44)

  • @blasumlily3485
    @blasumlily34857 жыл бұрын

    i use something i call group comparison. i have a unified axiom on how to sort, by color i just lay out an imaginary spectrum going from one extreme to the other, and then place them in correct order, by matching items to places on the spectrum.

  • @jordanrodrigues1279

    @jordanrodrigues1279

    5 жыл бұрын

    That is only faster if you know the data belongs to a particular distribution. But if you do have that knowledge, then distribution sorts like flashsort are faster than comparison sorts demonstrated by this video.

  • @myssangela4872
    @myssangela48723 жыл бұрын

    Brightest ball is put aside Tree: _wait, that's illegal_