Bubble Sort algorithm implementation in Python

27
77



Learn about Bubble Sort and how to write a Bubble Sort algorithm from scratch in Python.

Hope you enjoyed the video!

Check out this code here:

Join my Discord server to chat with me:

Check out some code on my GitHub:

Tweet me something funny on Twitter:

Say hi over at Facebook:

Sincerely,
Engineer Man

Nguồn:https://quydinh.com/

27 COMMENTS

  1. I know a couple of things about programming (nowhere near being a pro since in my studies I was taught half a year this, half a year that (and so on) – without Google to look stuff up I can do very little), but Python was totally new to me (well, I've never written any and looked through about two Python scripts before today).
    Today I watched your Python Basics series and decided to do a bit more. I thought this looked interesting, but after clicking on it I thought "Wait, can I do this myself?". The Bubble Sort is something I haven't written before, so new language and new algorithm!
    And sooo… it took me a quite a bit longer than this video (which I haven't watched yet, but will soon) (but less than an hour, I believe, even with doing more than the bare minimum: a) I had to look up how to check the input and discard anything not a number b) I had to look up how to translate the output so there aren't brackets or commata, because I believe outputting stuff in a format the script can't parse is bad form), but I've gotten it right!

  2. Hey Engineer Man, what do you think about a recursive approach to this problem? Like this: https://github.com/Pfuufy/bubble_sort.py

  3. Hey engineerman, i really like your videos. Is it possible to make videos on CTF and reverse engineering? Thanks in advance

  4. I absolutely love your style. I am pretty new to Python, and have found the way you present and teach to undoubtedly be the most effective way I am able to learn. I've not found anywhere else where Python is taught in a 'project' type manner rather than in the functional/syntactic manner we see everywhere else. Not that this is bad, but your technique is class. Thank you.

  5. Can you open an external file and sort, perhaps a names list alphabetically or a list of phone numbers/serials numerically?

  6. Windows's CMD gives me the following error when trying to run the program:
    File "BubbleSort.py", line 13

    print sort ([1, 2, 3, 4, 5, 6])

    ^

    SyntaxError: invalid syntax

    IDK if it's because I'm on Windows. That was the problem for me in the Snake-game.

  7. Hey engineer man, I was wondering if you could do a video on drawing complex structures and/or graphs using loops and/or arrays! Nice video btw! Thanks!
    😀

  8. after swaping. corrected will be True..and at last condition of if not corrected,it must return arr only if it is false..Then how is this working fine..plz explain (if not corrected) stuff..i confused..

  9. Hey Engineer Man, I have a challenge for you:
    – the bucket challenge –
    let's say you have 4 buckets,
    bucket 1 = 7
    bucket 2 = 4
    bucket 3 = 8
    bucket 4 = 3

    you have to develop something that can fill from one bucket to another in a decreasing way to have the maximum of buckets with a value of 10.

    you take out the second bucket to complete the first, then the third to complete the second, and so on.

    for the result to be:
    bucket 1 = 10
    bucket 2 = 10
    bucket 3 = 0
    bucket 4 = 2

  10. Python is my language of choice & would love to see more videos from you using this. While I know you're teaching about the bubble sort algorithm, it might also be good to mention that python can natively sort a list with "arr.sort()". Just a gee-wiz thing. And I didn't know about that cool little swap you did with "arr[i], arr[i+1] = arr[i+1], arr[i]". Very nice.

LEAVE A REPLY

Please enter your comment!
Please enter your name here