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!
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!
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.
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
Anastacia Kay The two lines you mentioned first creates a outer loop and then the second one creates an inner loop. For each iteration in the outer loop, the inner loop will be executed. The range functions can take 3 arguments: range(start, stop, step). The step arguments indicates how much the iterator variable should increment for each iteration.
in case you still wants to know lol... The second For loop is for to reiterate through the list because it might not be sorted in single loop.... The top loop makes it run through the list again to sort the leftovers...
This is freaky copy paste for loop all videos have on net and no one explains the logic. This video made concept clear and explained it clearly. So do not mess up, just use this.
Basically once all the iterations in the for loop are executed and the if statement inside is finished it will a excute the if and break out since it was set to false earlier and only now is getting executed because it was set false earlier meaning it will break
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: ruclips.net/video/Vca808JTbI8/видео.html
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!
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!
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.
You are the best algorithm teacher. Thank you so so much.
I watched a lot of videos but didn't understand until I discovered you. Thank you so much
Very good, well demonstrated, I like it. I shall check out a few more of your vids, thanks very much.
Thank you, everything else that I found was very confusing but thanks to this video I understand this much better
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
YUp, that is what I was wondering.
Nice Explanation without using animation, bubbles and taking each value.
You can write lst[i],lst[i+1]=lst[i+1],lst[i]
Beautiful tutorial. what font did you use in your code editor
he commented the index!! I'm your new subscriber 🔥
NICE VIDEO MAN!
that voice gives me peace
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
Anastacia Kay The two lines you mentioned first creates a outer loop and then the second one creates an inner loop. For each iteration in the outer loop, the inner loop will be executed.
The range functions can take 3 arguments: range(start, stop, step). The step arguments indicates how much the iterator variable should increment for each iteration.
in case you still wants to know lol...
The second For loop is for to reiterate through the list because it might not be sorted in single loop.... The top loop makes it run through the list again to sort the leftovers...
This is freaky copy paste for loop all videos have on net and no one explains the logic. This video made concept clear and explained it clearly. So do not mess up, just use this.
thank you very much, it was very helpful.
hey can you give me a link to the python coding language that you use please???
Why did u put the index till 9 in the second loop? Anyone??
he never made another sorting video :'(
can anyone explain for me the logic of breaking the outer loop (j) when setting the Boolean check_for_swap = True? Thanks
Basically once all the iterations in the for loop are executed and the if statement inside is finished it will a excute the if and break out since it was set to false earlier and only now is getting executed because it was set false earlier meaning it will break
A,B=B,A is swap.
Thank you
awesome
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:
ruclips.net/video/Vca808JTbI8/видео.html
Thnx