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!

FB –

Insta –

Twitter –

LinkedIn –

GitHub –

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

Always looking for suggestions on what video to make next — leave me a comment with your project! Happy Coding!

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

### Xem thêm Bài Viết:

- Chia sẻ đầy đủ về cách hướng dẫn Ghost Win Xp bằng USB cơ bản từ A tới Z
- Hướng dẫn tạo file ghost win 10 thông qua 3 bước đơn giản mà bạn không nên bỏ qua
- Mách bạn 4 bước trong cách bung file tib theo chuẩn UEFI đơn giản nhất
- Mật bí 4 kiểu hyperlink trong excel bị lỗi phổ biến mà bạn hay gặp nhất
- Khái niệm ma alt là gì và cách sử dụng bảng mã ATL như thế nào?

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

New subscribe here

If there are flowchart, tracetable and pseudocode inclding in this video as well, it would be very helpful for some students who study computing foundation.

This video show simplicity and great explanation for reading the Head First: Learn to Code

Are you going to do one for mergesort too?

sir it is inot working when i am running this programme , it returns me that bubble sort is not defined it"s my doubt and please sir clear it ASAP!

Thank you . well explained

Did he just reduce the time complexity of bubble sort algorithm from O(n^2) to O(n) ??????

Great video but I would like to know if its possible to place in variables in the algorithm to sort as I would like to create a leaderboard where it shows the username of the player and the score they got in the end

This is great stuff. Pls continue making videos

Good video and explanation are clear !

Excellent videos…

Excellent Vid, keep it

Thanks for your videos. They're well presented and quality is crisp!

thanks

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!

Hey, Derrick nice video as always, I am just playing all your videos looking for ideas for graduation final assignment work for my college. Maybe do you have any? It could be anything IT & finance related