Bubble sort in 2 minutes

  Рет қаралды 1,027,569

Michael Sambol

Michael Sambol

Күн бұрын

Пікірлер: 281
@istiaqahmed8309
@istiaqahmed8309 3 жыл бұрын
After completing a 30 minutes lecture on the topic this video is like a dessert after dinner.
@SzechSauce
@SzechSauce 5 жыл бұрын
These videos are great, 30mins of my lecture summarized in 2mins lol
@pxolqopt3597
@pxolqopt3597 4 жыл бұрын
30 minutes to explain bubble sort? Really?
@prometheus-naturalscience9371
@prometheus-naturalscience9371 2 жыл бұрын
@@mtosity Usually a CS lecture on something like this would also include proofs for correctness, and time and memory complexity. Dont think it adds up to 30 minutes, but its obviously a lot more than what is shown here, which basically just the idea of the algorithm and an example.
@tanveebandi1090
@tanveebandi1090 2 жыл бұрын
True😂
@AnkurSingh-uc7gz
@AnkurSingh-uc7gz 2 жыл бұрын
In min😂 2X
@100_focus
@100_focus 2 жыл бұрын
wait u guys are learning this in uni???
@r0btaylor
@r0btaylor 2 жыл бұрын
I only recently found your channel and I'm finding your style and clarity to be especially effective for my learning. Just wanted to let you know how much I've been appreciating your content. Thanks!
@MichaelSambol
@MichaelSambol 2 жыл бұрын
I appreciate you watching, thank you!
@kewtomrao
@kewtomrao 3 жыл бұрын
His two minutes of silent teaching was better than an hour of our lecturer's class.
@realwizardry834
@realwizardry834 6 жыл бұрын
Love this visual way of learning. Thank you for the work put into this
@lucutes2936
@lucutes2936 Жыл бұрын
ye
@abzinhoo
@abzinhoo Жыл бұрын
Ah
@lukebrown2498
@lukebrown2498 Жыл бұрын
Hello, i'm a student from the UK and my course requires me to learn a lot of the sorting algorithms that you have shown. Usually, only resources from people specifically covering the course is helpful, but these visual aids have been really effective and engaging, so thanks so much
@MichaelSambol
@MichaelSambol Жыл бұрын
glad the videos helped! thanks for the note.
@ronitmehta2594
@ronitmehta2594 4 жыл бұрын
I am a visual learner so I found this extremely helpful!
@ichoosemeimsorry
@ichoosemeimsorry Жыл бұрын
lmaoooo i cant believe i managed to understand what i have been struggling with the whole semester in 2 minutes. thanks man
@omersakkar5670
@omersakkar5670 6 ай бұрын
Thanks for the explination. I wanted to point out that you can right much more effecient code: for i = 0 to n-1 for j = 0 to n-i-2 if array[j] > array[j+1] swap(array[j], array[j+1])
@ravs
@ravs 6 жыл бұрын
Very simple and concise way to explain this algorithm. Keep up the good work and looking forward to more videos.
@Raum_Raum_Raum_Raum
@Raum_Raum_Raum_Raum 4 жыл бұрын
Shush bitch
@Krokodil986
@Krokodil986 5 жыл бұрын
amazing video - short, precise, and explains very well
@eeevoo
@eeevoo 4 жыл бұрын
@@Raum_Raum_Raum_Raum damn why so toxic
@陳致揚
@陳致揚 6 ай бұрын
I have watched your all videos several times whenever i need to review the algorithm, " You Are Definitely A God Of Algorithm"
@romysasiddiqui2859
@romysasiddiqui2859 Жыл бұрын
you're videos are more helpful than other videos that are 30 to 40min long and yet at the end still are confused.
@valvarexart
@valvarexart 8 жыл бұрын
Very nice and to-the-point videos, thank you! A small note: bubble sort would perform better if n was decreased after each iteration (reflecting the fact that the last element is in its final position) and if we keep track of whether swaps have been made or not during a round (if not, we can just terminate).
@stefanjovanic7725
@stefanjovanic7725 5 жыл бұрын
I was looking for this explanation that's how simple it is for some people. Two sentences to explain what is going on.
@shalev1234
@shalev1234 5 жыл бұрын
And I think also every even iteration a bubble of small elements to the left will be good for a case that a small element is on the right side of the array.
@jliu66-p1q
@jliu66-p1q 2 жыл бұрын
the best optimization is setting your outter loop stop index to be the last swapped index of your inner loop. This makes it more naturally adaptive than keeping track of a swaps made boolean
@manmeh4r
@manmeh4r 3 жыл бұрын
now THIS is the best bubble sort guide ever
@farhatzuhair7729
@farhatzuhair7729 Ай бұрын
Thanks, I cleared my exam easily by watching this
@techytech07
@techytech07 Жыл бұрын
Thanks for a clear and simple video! It's Helping for my GCSE this May. Some people just overcomplicate these sort methods.
@NB20LOL
@NB20LOL 3 ай бұрын
Very helpful, have a test in 2 days and know almost everything on this topic
@hydhexane
@hydhexane Жыл бұрын
i have exam tomorrow, this video helped me revise bubble , thanks
@MichaelSambol
@MichaelSambol Жыл бұрын
crush it!
@juicetime222
@juicetime222 10 ай бұрын
I have an exam soon, this video really helped!
@luke9524
@luke9524 5 жыл бұрын
Incredible video, you're style of teaching is very easy to understand.
@kerbe5374
@kerbe5374 3 жыл бұрын
Bruh is this really what took my professor most of the class trying to explain😭 thank you so much for this
@TheGugustar
@TheGugustar 2 жыл бұрын
Best algo channel on youtube.
@priyanshuagrawal9204
@priyanshuagrawal9204 2 жыл бұрын
Thankyou from saving me from watching 1 hour lecture, when I am in rush before exams
@SniperFire274
@SniperFire274 3 жыл бұрын
Best video I've seen to explain bubble sort, thank you!
@chiragshilwant886
@chiragshilwant886 5 жыл бұрын
According to your code, Number of comparisons is n(n-1) but it can be reduced to n(n-1)/2 by setting j upto n-i-1
@ramviswanadhapalli4397
@ramviswanadhapalli4397 Жыл бұрын
i was thinking about the same thanks for the confirmation
@FrenziedSol
@FrenziedSol 2 жыл бұрын
This animation absolutely made me understand the bubble sort
@JohnWickXD
@JohnWickXD 3 жыл бұрын
This channel is underrated man!
@HarunAltay
@HarunAltay 7 жыл бұрын
Thanks Michael. Great job! But I guess pseudu code is wrong. It may be: for (int i = 0; i < array.length; i++) { for (int j = 0; j < array.length - 1 - i; j++) { if (less(array[j + 1], array[j])) exchange(array, j, j + 1); } }
@piyushsahoo3636
@piyushsahoo3636 Жыл бұрын
yes both are correct but yours is more optimized
@nicolasrodriguez1499
@nicolasrodriguez1499 4 жыл бұрын
Thanks dude, this shorts videos are saving me for my algoritm exam! Thanks!
@MuntahaZad
@MuntahaZad 4 жыл бұрын
Thanks! No music and no trash!
@Pwnedby
@Pwnedby Жыл бұрын
I literally coded it after u explaining it to me. This helped soo much!
@roaamoustafa3488
@roaamoustafa3488 Жыл бұрын
Hello, i just eant to thank you for you effort in this short videos I have adhd and I always find it so hard to understand CS concepts such as datastructers and long videos don't work for me at all also I am a visual learner so, I'm really thankful!
@MichaelSambol
@MichaelSambol Жыл бұрын
you're welcome!
@Ali-mi9up
@Ali-mi9up 5 жыл бұрын
Those saying that pseudocodes is wrong are incorrect, you can have another implementation that's right too
@vincenzocammilleri2907
@vincenzocammilleri2907 3 жыл бұрын
All your sort videos were awesome!!! Thank you so much bc I needed it for my final tmw lol
@yikayiyo2920
@yikayiyo2920 6 жыл бұрын
for i from 1 to N: # N-1 iterations to sort a N-length list for j from 0 to N-i: # after i iterations ,the last i elements are sored
@UtshaKSaha
@UtshaKSaha 5 ай бұрын
This was such a good video, some things just need visualizations.
@hakonaskildsen2602
@hakonaskildsen2602 Жыл бұрын
Thank you so much for amazing videos! Great repetition before exams.
@secretnobody6460
@secretnobody6460 24 күн бұрын
so much better than my 3 hour lectures
@saddlepiggy
@saddlepiggy Жыл бұрын
Awesome videos, great refreshers before finals
@MichaelSambol
@MichaelSambol Жыл бұрын
💪🏼❤️
@VihaanKumar-o1s
@VihaanKumar-o1s 10 ай бұрын
excellent explanation.........very simple and easy to understand
@player-vo8yb
@player-vo8yb 3 жыл бұрын
i like these short vids to the point and no padding like those other shitty ass vids thank you kind sir
@billionear
@billionear 2 жыл бұрын
Awesome simple and straight to the point - subscribed!
@vendita2
@vendita2 4 жыл бұрын
Thank u, didnt have time for big explanations
@entruh4520
@entruh4520 4 жыл бұрын
Thanks man. Wish me luck for my test tomorrow
@kingcookie3920
@kingcookie3920 5 жыл бұрын
the pseudocode works but I would do "N-i" instead of "N-1"
@jesusbojorquez2252
@jesusbojorquez2252 5 жыл бұрын
N - i - 1
@kingcookie3920
@kingcookie3920 5 жыл бұрын
@@jesusbojorquez2252 why? i starts with 1. First round you need to compare 6 times. That is N-1 Second you compare 5 times. That is N-2 Overall you have to do this 6 times (Not an insult, I am probably just don't get it)
@jesusbojorquez2252
@jesusbojorquez2252 5 жыл бұрын
@@kingcookie3920 I wrote N - i - 1 because if you look at the second for it goes from 0 to N -1, so when j == N - 1 it will compare a[N - 1] with a[N] which doesn't exist in the array. "FIrst round you need to compare 6 times" yes that's right but remember that the second for start from 0 so you don't need to go to N-1 you just need to go to N - 2.
@renzserilo7142
@renzserilo7142 4 жыл бұрын
Just an ordinary boy here just to read these comments, i’m not crazy to argue with a king specially with jesus.
@svenwillett1750
@svenwillett1750 4 жыл бұрын
You're doing an advanced bubble pass, a normal one still does the rest even though you know the last is known.
@random-0
@random-0 3 жыл бұрын
Best video on bubble sort
@MohammadJavadd
@MohammadJavadd 7 ай бұрын
Finally understand it, thanks so much
@monjasonsteng7861
@monjasonsteng7861 4 ай бұрын
This was great. Thank you!
@alexanderhearn6015
@alexanderhearn6015 Жыл бұрын
I love having to put the video in 2x speed. This should be a 20 second video
@MichaelSambol
@MichaelSambol Жыл бұрын
Go as fast as you need :) I talk slow.
@radhikasoni8105
@radhikasoni8105 5 жыл бұрын
Brilliant explanation!! Please make a video on Radix sort.
@magickomchanell4556
@magickomchanell4556 4 ай бұрын
Very helpful thanks for the video!
@sanadesai13
@sanadesai13 4 жыл бұрын
@michael, Thanks for the video, but shouldn't the second FOR loop be "for j from 0 to N-2". i.e till the second last element. Because if it reaches "N-1" i.e the last element then j+1 = N which will give out of bound error.
@RAHULTMNT100
@RAHULTMNT100 2 жыл бұрын
you are correct the values should be, i < nSize - 1 ( as i reaches nSize -1 , array will be sorted) j < nSize - i - 1 ( after i iterations, the last i elements are already sorted)
@CephasTheWanderer
@CephasTheWanderer 5 жыл бұрын
Awesome. Short, sweet, simple
@Erikuri
@Erikuri 8 ай бұрын
Thank you! This really was helpful.
@cg8770
@cg8770 4 ай бұрын
Nice video!! It helped me a lot
@nirkiotaxy
@nirkiotaxy 5 ай бұрын
ООООО, НАКОНЕЦ Я ПОНЯЛ ЭТОТ МОМЕНТ!!! То, что при первом прохождении цикла, большее число однозначно отсортируется и будет стоять в конце массива, из-за чего можно не проводить последующие проверки с ним
@evanspicolo6493
@evanspicolo6493 3 жыл бұрын
Nice video! Helpped I lot to teach this
@ettsoc9018
@ettsoc9018 Жыл бұрын
great and efficient to learn like this
@JamesBrodski
@JamesBrodski 3 жыл бұрын
Great video! Thank you so much.
@FunnyOnes1xx
@FunnyOnes1xx Жыл бұрын
this was very helpful, Thank you!
@MichaelSambol
@MichaelSambol Жыл бұрын
De nada!
@이석원-x9p
@이석원-x9p 5 жыл бұрын
I like colors you made.
@lindamanas954
@lindamanas954 2 жыл бұрын
Nicely done!
@abdosalah22
@abdosalah22 2 жыл бұрын
Great explanation!
@Withmusclecutie
@Withmusclecutie Ай бұрын
Wouldnt it be more efficient if it didnt look at the number combos that didnt change
@jeshmex
@jeshmex 2 жыл бұрын
Thank you so much, very helpful!
@prashanthreddy1502
@prashanthreddy1502 4 жыл бұрын
The bubble sort method is a nice and simple method of sorting an array. It however looks to be very time consuming and inefficient as it would have to run almost as many times as the size of the array and it would be highly inefficient with larger arrays. #IISH11CSHLIC
@midasredblade236
@midasredblade236 2 жыл бұрын
prolly usefull in special cases
@yblue6116
@yblue6116 2 жыл бұрын
you saved me, thanks a lot man
@lukehatcher98
@lukehatcher98 4 жыл бұрын
Just what I needed!
@mahdighasemi9518
@mahdighasemi9518 3 жыл бұрын
very good, thank you❤️👍
@afaqa.s.9887
@afaqa.s.9887 5 жыл бұрын
Simply, awesome...
@jamaicandjnado
@jamaicandjnado 5 жыл бұрын
Perfection. Thank you.
@minkymoo5773
@minkymoo5773 3 жыл бұрын
So bubble sort is a bit like the opposite of selection sort, isn't it? Since with selection sort, you have a sorted partition on the left at any given iteration, and with bubble sort you have a sorted partition on the right at any given iteration.
@cravinghydra30
@cravinghydra30 4 жыл бұрын
Bubble Sort is the simplest sorting algorithm that works by repeatedly swapping the adjacent elements if they are in wrong order and it arranges them in increasing order.#IISH 11CSHLIC
@nty449
@nty449 4 жыл бұрын
my teacher showed us this dumb ass dance thing and I was like WTF IS THIS GARBAGE. this is so much more helpful thank you. I actually get it now
@NyashaMandizvidza-vp3do
@NyashaMandizvidza-vp3do Жыл бұрын
This is amazing
@ReapeX
@ReapeX 3 жыл бұрын
Subscribed, thanks!
@ricardoancona9722
@ricardoancona9722 3 жыл бұрын
for an strange reason, running this pseudocode in python has a bug, I don't know why, but comparing 2 elements of the list, for example: 4>23, returns TRUE, because. it seems to be comparing only the first digit (4>2), I solved it by converting the current value and the next value to integer before comparing, does anyone know why this happens?
@JuanArth378
@JuanArth378 4 жыл бұрын
Thank you it was very helpful
@Tim1-z6b
@Tim1-z6b Жыл бұрын
Bubble sort Javascript code: function bubbleSort(arr) { for (let i = 0; i < arr.length; i++) { for (let j = 0; j < arr.length - i - 1; j++) { if (arr[j] > arr[j + 1]) { let temp = arr[j]; arr[j] = arr[j + 1]; arr[j + 1] = temp; } } } return arr; }
@memenchance1747
@memenchance1747 2 жыл бұрын
I know how to do the problem but I don't know how to tell the computer how long I want this process to continue. Do you have any suggestion of books to read or watch?
@joebradley1239
@joebradley1239 7 жыл бұрын
Great video! im doing GCSE computer science and i was just wondering what would an exam style question look like? would it simply ask to sort these numbers using a bubble sort (show your working) or breifly explain what a bubble sort does? thankyou
@antoniojg-b8284
@antoniojg-b8284 6 жыл бұрын
In my experience, it's likely the first one.
@ameliewolfbane7733
@ameliewolfbane7733 6 жыл бұрын
One question might be what will the last two numbers be after the first iteration (the answer would be 1 , 9)
@HabirRibah
@HabirRibah 5 жыл бұрын
You're great. Thank you
@iamusmanshabbir142
@iamusmanshabbir142 3 жыл бұрын
Real Gem 💎
@StewieGriffin
@StewieGriffin 5 жыл бұрын
Bubblesort is basically the MOST BASIC SORT EVER
@ctoxyz
@ctoxyz 2 жыл бұрын
humans hav voice for reason : nice work
@sean_hare
@sean_hare 4 жыл бұрын
This psuedocode works, but it's literally doing twice the number of iterations it needs to, and this is wasteful code. It should be: For i = N-1 to 0 For j = 0 to i if a[j] < a[j+1] swap(a[j], a[j+1]) If after the first pass of j, the highest value in the array will be sitting in N. Knowing this, the second pass of j should terminate one space earlier, which will happen when i decrements toward 0.
@mastermax7777
@mastermax7777 Жыл бұрын
shouldnt the second loop only go until N-i ?
@shafaf1
@shafaf1 4 жыл бұрын
Simple and understandable
@asagiai4965
@asagiai4965 3 жыл бұрын
is it me or this is probably the slowest sorting algo? thanks for a more clear explanation
@devops-k1p
@devops-k1p Жыл бұрын
Currently done with 2h lecture, now time for 2h lab. Leave me alone bubble sort!
@Jschmuck8987
@Jschmuck8987 Жыл бұрын
so, essentially, the worst case scenario is where it's already sorted but in reverse order, right?
@riyamani8161
@riyamani8161 4 жыл бұрын
#IISH 11CSHLIC The video helped me understand the process of bubble sorting and how the iteration works. It is a comparison of consecutive variables that gives the right form of number as the end result.
@DeepankSingh-u4p
@DeepankSingh-u4p Жыл бұрын
Hi Michael. Which software do you use for the animations in your videos?
@MichaelSambol
@MichaelSambol Жыл бұрын
Keynote and iMovie!
@DeepankSingh-u4p
@DeepankSingh-u4p Жыл бұрын
@@MichaelSambol okay. Thanks.
@amandasun6677
@amandasun6677 Жыл бұрын
Small typo: I believe in the pseudocode, the j loop should be from 0 to N-i
@varunbe09
@varunbe09 3 жыл бұрын
From @interviewkickstart I learned that, Its start comparison from right to left. So second for loop, For j from N to i Everything looks similar but here heavy element sorted at right. And Interviewkickstart video , in every steps lighter elements sorted at left
@lebogangsekwati4305
@lebogangsekwati4305 Жыл бұрын
God bless you!
@adithyam3202
@adithyam3202 2 жыл бұрын
im confused how you go from 1 to n and then from 0 to n-1. The smallest index in the array is 0, and the largest index in the array is n-1, right? so how can you go from index 1 to index n when index n does not exist?
@kafychannel
@kafychannel Жыл бұрын
thank you so much!
@tksnapz5003
@tksnapz5003 6 жыл бұрын
So helpful thank you!
Insertion sort in 2 minutes
2:19
Michael Sambol
Рет қаралды 1,4 МЛН
The Bubble Sort Curve
19:18
Lines That Connect
Рет қаралды 734 М.
The Best Band 😅 #toshleh #viralshort
00:11
Toshleh
Рет қаралды 22 МЛН
Try this prank with your friends 😂 @karina-kola
00:18
Andrey Grechka
Рет қаралды 9 МЛН
My scorpion was taken away from me 😢
00:55
TyphoonFast 5
Рет қаралды 2,7 МЛН
Арыстанның айқасы, Тәуіржанның шайқасы!
25:51
QosLike / ҚосЛайк / Косылайық
Рет қаралды 700 М.
Selection sort in 3 minutes
2:43
Michael Sambol
Рет қаралды 1,1 МЛН
Fast Inverse Square Root - A Quake III Algorithm
20:08
Nemean
Рет қаралды 5 МЛН
LeetCode was HARD until I Learned these 15 Patterns
13:00
Ashish Pratap Singh
Рет қаралды 704 М.
Bubble Sort | C Programming Example
14:53
Portfolio Courses
Рет қаралды 137 М.
Quick sort in 4 minutes
4:24
Michael Sambol
Рет қаралды 2 МЛН
Learn Bubble Sort in 7 minutes 🤿
7:44
Bro Code
Рет қаралды 312 М.
Why You Can't Bring Checkerboards to Math Exams
21:45
Wrath of Math
Рет қаралды 435 М.
Heap sort in 4 minutes
4:13
Michael Sambol
Рет қаралды 1 МЛН
The Best Band 😅 #toshleh #viralshort
00:11
Toshleh
Рет қаралды 22 МЛН