Python Programming Series (Sorting): Bubble sort

preview_player
Показать описание
This goes over the bubble sort algorithm.
Рекомендации по теме
Комментарии
Автор

LEMME tell you one thing, no video on internet exists to explain clearly while coding why we use two loops and temp variable. There are tons on videos that explain logic first and then simple give the codes. You explained the logic while coding. You deserve billion subscribers. Great job!

arunkumaracharya
Автор

Hey, Tom, I am a GCSE student studying computer science and I was really stuck with my Bubble sort homework but because of you I really understand it so thank you so much keep up the videos on python, I might need them. Cheers!

tescoservices
Автор

I paused at 4:28 and I made the working algorithm all by myself in under 10 minutes:

lst = [5, 2, 6, 3, 8, 7, 1, 9, 4]
c = 1
while c < len(lst):
n, c = 1, 1
for x in lst:
if x == lst[len(lst)-1]:
break
elif x > lst[n]:
lst[n-1] = lst[n]
lst[n] = x
else:
c += 1
n += 1

It's not as cool as yours but I'm still learning.

kristijanross
Автор

You are the best algorithm teacher. Thank you so so much.

ok-kyunim
Автор

I watched a lot of videos but didn't understand until I discovered you. Thank you so much

alpertorun
Автор

You can write lst[i], lst[i+1]=lst[i+1], lst[i]

sreekanthk
Автор

Nice Explanation without using animation, bubbles and taking each value.

vinoddiwan
Автор

so bad that python were not that popular back then so his videos did not receive a lot of views. Hopefully this guy come back to do python tutorials

chieuta
Автор

Thank you, everything else that I found was very confusing but thanks to this video I understand this much better

Laura-
Автор

Very good, well demonstrated, I like it. I shall check out a few more of your vids, thanks very much.

indigogolf
Автор

he commented the index!! I'm your new subscriber 🔥

vatsal_gamit
Автор

Beautiful tutorial. what font did you use in your code editor

dejiomofaiye
Автор

Why did u put the index till 9 in the second loop? Anyone??

alishbamumtaz
Автор

Hi Tom! Thanks so much for your videos, I'll make sure to watch the whole algorithms playlist now :)

Just (what I hope is) a quick question:
I don't quite get the first two lines, which in my class we put down this way:
for j in range(len(alist)-1, 0, -1):
for i in range(j):

Why do we need to repeat the -for- thing? I understand that this creates the loop, but don't get why/how.
And also how to decode this (len(alist)-1, 0, -1)?

Thank you in any case!
Anastacia

funastacia
Автор

thank you very much, it was very helpful.

sarato
Автор

hey can you give me a link to the python coding language that you use please???

denholmsinclair
Автор

he never made another sorting video :'(

linnil
Автор

can anyone explain for me the logic of breaking the outer loop (j) when setting the Boolean check_for_swap = True? Thanks

diepnhu
Автор

Great video, but can you please explain how this would work if we did len(lst) as our total length of the list? Obviously explaining what to do if we wanted to change the number in our list without having to rewrite our range each time?
This would be a massive help to me, I saw it online as this len(lst)-1, 0, -1 but I am baffled by this: the link for this is below:

alexw.e.