Bubble Sort Algorithm Explained (Full Code Included) - Python Algorithms Series for Beginners

preview_player
Показать описание
Bubble Sort is a simple sorting algorithm that repeatedly swaps two adjacent elements through iterations through the list length to create a sort list.

The Bubble sort algorithm is one of the simplest algorithms to learn in computer science and is a great starting point to learn tougher algorithms.

In this one we'll cover how to implement the bubble sort algorithm using python programming.

#Python #BubbleSort #Algorithm

Join The Socials -- Picking Shoutouts Across YouTube, Insta, FB, and Twitter!

Thanks so much for the continued support of the videos! 5320+ subscribers at the time of writing. So awesome. Thank you all for supporting the content I make! It's incredible to get the opportunity to make these videos for you all. Thanks so much!
*****************************************************************
Full code from the video:
def bubble(list_a):
indexing_length = len(list_a) - 1 #SCan not apply comparision starting with last item of list (No item to right)
sorted = False #Create variable of sorted and set it equal to false

while not sorted: #Repeat until sorted = True
sorted = True # Break the while loop whenever we have gone through all the values

for i in range(0, indexing_length): # For every value in the list
if list_a[i] #"Angled brackets not allowed in Youtube Description :( list_a[i+1]: #if value in list is greater than value directly to the right of it,
sorted = False # These values are unsorted
list_a[i], list_a[i+1] = list_a[i+1], list_a[i] #Switch these values
return list_a # Return our list "unsorted_list" which is not sorted.

print(bubble([4,8,1,14,8,2,9,5,7,6,6]))

Packages (& Versions) used in this video:
Python 3.7

*****************************************************************
Code from this tutorial and all my others can be found on my GitHub:

Check out my website:

If you liked the video - please hit the like button. It means more than you know. Thanks for watching and thank you for all your support!!

--- Channel FAQ --

What text editor do you use?

What Equipment do you use to film videos?

What editing software do you use?
Premiere Pro for video editing
Photoshop for images
After Effects for animations

Do I have any courses available?
Yes & always working on more!

Where do I get my music?
I get all my music from the copyright free Youtube audio library

Let me know if there's anything else you want answered!

-------------------------

Always looking for suggestions on what video to make next -- leave me a comment with your project! Happy Coding!
Рекомендации по теме
Комментарии
Автор

There are thousands of python tutorials on the internet but this dude has the attitude of "keep it simple, stupid" which suits me fine as a beginner who asks stupid questions. Thank you👏

BN-hynd
Автор

Man, you're a godsend! Such a crisp and on-point elucidation, I've never felt anything clearer than this in my life!

vidushimohan
Автор

This is the first time of thousands, that I check a tutorial o YT and I see no troubles with me understanding it... Simple and easy! Thanks

gachle
Автор

Nice, you kept it very simple.
A quick improvement tip: in every outer loop you can actually decrease the index length since bubblesprt always sorts the biggest element each iteration.

andrewtate
Автор

This is great stuff. Pls continue making videos

leonquadros
Автор

Fell in love with the way, you explain things. It's easy to grasp. Please keep posting the videos. (if possible, could you please post a video on recursion and how to apply it in different scenarios). Thank You

uppalapraveen
Автор

Great video - very clearly explained and helped the penny drop very quickly!

vewyudb
Автор

Really a fan of your videos. Well presented every time and it keeps getting better and better. Keep up the good work. This series seems very interesting. Cheers!

timohelasvuo
Автор

after 4 years this is by far the best video

codeNexus-bbmb
Автор

People go to indians for tutorial and I'm an indian coming to you for tutorial 😂

Impedance_Z
Автор

Been searching for so many explanations for sorting and I get it, but yours have been the easiest to understand by far. Godly!

kharlopena
Автор

Boss I have solved the problem when you said to try it by myself. You are the extraordinary teacher I could ever find.

tareqmahmud
Автор

Great explanation. I've been trying to wrap my head around this one for a minute.

TechEndeavor
Автор

Bro u are an absolute legend. I was trying to learn this from my teacher but did not understand anything but after watching this video I have no more doubt. TYSM

adithyaramesh
Автор

In my opinion, this is a more elegant solution than the two for loops a lot of other videos suggest using. This makes more intuitive sense, thank you!

fareselamine
Автор

how tf is this dude not huge this shit is life saving

thescoobiestdoo
Автор

Hi Derrick, please start making video from begging for python!. You really explain the bubble sort very clearly.Please make more videos in python programming. Thanks

paula
Автор

The easiest tutorial to follow, straight to the point, will definitely recommend this to my colleagues.

serranoaaronjamesv.
Автор

Great, short and straight to the point explanation!

thedataprofs
Автор

I was lost and unable to code this until I watched your video, I am very thankful for the help you've provided me! I am looking forward to using your channel to learn more.

banquotheholstein