Python Programming Series (Sorting): Bubble sort

Поделиться
HTML-код
  • Опубликовано: 8 янв 2025

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

  • @arunkumaracharya9641
    @arunkumaracharya9641 4 года назад +7

    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!

  • @tescoservices9732
    @tescoservices9732 6 лет назад +13

    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!

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

    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.

  • @ok-kyunim1767
    @ok-kyunim1767 7 лет назад +5

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

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

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

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

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

  • @Laura-3117
    @Laura-3117 2 года назад

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

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

    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

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

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

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

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

  • @dejiomofaiye5660
    @dejiomofaiye5660 4 года назад +2

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

  • @vatsal_gamit
    @vatsal_gamit 4 года назад +1

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

  • @zackr1743
    @zackr1743 4 года назад +3

    NICE VIDEO MAN!

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

    that voice gives me peace

  • @funastacia
    @funastacia 8 лет назад +3

    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

    • @iYankrozHD
      @iYankrozHD 7 лет назад

      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.

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

      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...

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

      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.

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

    thank you very much, it was very helpful.

  • @denholmsinclair3483
    @denholmsinclair3483 7 лет назад +2

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

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

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

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

    he never made another sorting video :'(

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

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

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

      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

  • @GNNN-gw9tk
    @GNNN-gw9tk 5 лет назад +2

    A,B=B,A is swap.

  • @efazmahmud861
    @efazmahmud861 2 года назад

    Thank you

  • @rajkamaldas100
    @rajkamaldas100 7 лет назад +1

    awesome

  • @alexw.e.1390
    @alexw.e.1390 5 лет назад +2

    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

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

    Thnx