Learn Bubble Sort in 7 minutes 🤿

preview_player
Показать описание
Data structures and algorithms bubble sort tutorial example explained

#bubble #sort #algorithm

// bubble sort = pairs of adjacent elements are compared, and the elements
// swapped if they are not in order.

// Quadratic time O(n^2)
// small data set = okay-ish
// large data set = BAD (plz don't)

music credits 🎼 :
===========================================================
===========================================================
Creative Commons — Attribution-ShareAlike 3.0 Unported— CC BY-SA 3.0
===========================================================
Рекомендации по теме
Комментарии
Автор

public class Main{

// bubble sort = pairs of adjacent elements are compared, and the elements
// swapped if they are not in order.

// Quadratic time O(n^2)
// small data set = okay-ish
// large data set = BAD (plz don't)

public static void main(String[] args) {

int array[] = {9, 1, 8, 2, 7, 3, 6, 4, 5};

bubbleSort(array);

for(int i : array) {
System.out.print(i);
}
}

public static void bubbleSort(int array[]) {

for(int i = 0; i < array.length - 1; i++) {
for(int j = 0; j < array.length - i - 1; j++) {
if(array[j] > array[j+1]) {
temp = array[j];
= array[j+1];
= temp;
}
}
}
}
}

BroCodez
Автор

The comparison with the two cups was really intuitive! I wish someone had explained me variable swapping with that example.

dhoneybeekingdom
Автор

Bro you are just amazing, i really appriciate your works .. Please keep going

moum.a
Автор

Out of all the basic ways of sorting, this is the slowest of the basic ways to sort

jaykay
Автор

You are saving my life in cs classes. Thank you so much.

pdyprux
Автор

These videos are great. Really helpful for my studying, thank you

Zippo_
Автор

U r videos are my go to for all the sorting algos, Thank you for making these, Great help, Keep up the great work!

ashmikanln
Автор

legit only channel I have notifications on for, lifesaver!

poromoro
Автор

For the second for-loop
for(int j = 0; j < array.length - i - 1; j++)
Why must we subtract i and one? I understand why we need to subtract one but why i?

sakuriosky
Автор

I know it already but I appreciate your effort. I currently know bubble sort, selection sort, insertion sort, binary and linear search as per my school syllabus. I will be waiting for your quick sort tutorial, I seriously want to learn it.

Anonymationsthecoolanimator
Автор

Bro is the best when it comes to explaining. I hope this guy blows up all over yt. I will support him

GamingPro-xnhy
Автор

I'm watching your videos from Brazil and I want to thank you for taking the time to teach us. It was very didactic to understand your explanation. Thank you very much.

leonardopensador
Автор

I had been looking for bubble sort written in basic. I found BBC2 book with a sample program, but the code was messy.
I managed to make easy to understand and I use it for personal applications. Like statistics.
A list of names and their statistics - e.g. (height, weight, age ) and put in order by any list.

vancemccarthy
Автор

thank you so much, it makes me easy, cause I watched alot of tutorials but don't understand.
yesterday I bought a C# course on udemy, the first video is talking how to make a Bubble sort, but i don't understand.
then my mind said: go on yotube, may be you can find a good teacher that makes simply to this fucking Bubble sort.
then i got you.

Now i understand the Bubble sort.

thank you so much..

mohamedabdirizakahmed
Автор

Bubble sort is a very easy algorithm to implement, but is quite inefficient with large data sets

Snowmanver
Автор

Thank you for your video. I think you need to break the loop if the array is already sorted for efficiency.

kyawsanaung
Автор

I'm from Colombia and I can understand all with this video, thx u (I love the manual example)

andres
Автор

you are great, just 15k subs away from the milestone! congrats

aditya_asundi
Автор

I still come back to this video from time to time to rehash my BubbleSort.

Thanks BRO!

barelycodingtoday
Автор

I love u!!!! Thank u for making the concept so clear n understandable💝

aliiiccyee
welcome to shbcf.ru