Bubble Sort Algorithm | How Bubble Sort Works with Example | Part - 1 | Sorting Algorithms DS

preview_player
Показать описание
Support Simple Snippets by Donations -
--------------------------------------------------------------------------------------------- Theory -
Bubble Sort is the simplest sorting algorithm that works by repeatedly swapping the adjacent elements if they are in wrong order.
his algorithm is suitable for small data sets
Its average and worst case complexity are of - (n^2) where n is the number of items.
It is known as bubble sort, because with every complete iteration the largest element bubbles up towards the last place or the highest index just like a water bubble rises up to the water surface.

Working -
Step 1 - Starting with the first element(index = 0), compare the current element with the next element of the array.
Step 2 - If the current element is greater than the next element of the array, swap them.
Step 3 - If the current element is less than the next element, move to the next element.
Step 4 - Repeat Step 1 till the list is sorted.

Simple Snippets Official Website -
Simple Snippets on Facebook -
Simple Snippets on Instagram -
Simple Snippets on Twitter -
Simple Snippets Google Plus Page -
Simple Snippets email ID -

Рекомендации по теме
Комментарии
Автор

Hey Guys, if you want more such tech educational videos on this channel then please support me by subscribing to this channel & also share it with your friends as it helps me create more content just for you ✌

SimpleSnippets
Автор

My friend trust me you are be best, I tried many options but I couldn't understand the algorithm; until when I watched your videos.

albertd.bangura
Автор

came here from part 2. I think this is the best ever explanation of bubble sort

LongDistance
Автор

Your channel will hit big numbers, I'm sure

dt
Автор

sir, here only 4 steps happen why have u taken the outer loop value from i=0 to i<n. I think the value of I should be i=0 to i<n-1. because the last data will be sorted automatically so we don't need to take 5 outer loops.

adarshranjan
Автор

Thanku bhaiya your dry run explanation is ultimate 🔥🔥🔥🔥🔥🔥

rajansingh
Автор

I think it should be i<n-1 instead of n

abhimanyu
Автор

I have watched only the half video and I am commenting. I like your way of teaching.

Tarun-Chauhan
Автор

Great teaching lots of efforts taken thank you 🙏

rupaligaikwadaug
Автор

Thank you so much . You are better million time than my doctor

ahmedalfarsi
Автор

Sir plz add questions to practice after every type of data structure.

saniyamansuri
Автор

Thank you so much for this! This was super super helpful!

krishveera
Автор

Bhai Iss course completion ka ik certificate hi rakh detay....Just suggesting

osamamustafa
Автор

@Simple snippets please include algo like djikstra, minimum spanning tree, b trees, avl trees,

etherealscaped
Автор

TANMAY BHAI aap bta sakty hain k how to find number of swaps for each pass in bubble sort in c++?

SIX-jirv
Автор

Hi. i found the videos very helpful. Thank you for sharing it with us.
on this video, I couldn't go after the sort becomes 3 6 2 7 9. on the next step, After i become 3 and j 0 couldn't get the required result. all turn out to be false that exit the inner loop and proceed until i is 4 which will give False for 2.1 loop. Please Assist/proceed from where you stop.

yosephteshomebirhanu
Автор

please add some practice questions and refrence book

maryumch
Автор

hi sir, we have just started with discrete structures and our teacher taught us that if we have an array of size n then we need to pass it through bubblesort program(in a loop) n-1 times, is that correct? Because I was looking at a page of Wikipedia, they had an array of size 5 and they only had 3 passes for it

komorebi-suki
Автор

Sir this algorithm is almost same as selection sorting algorithm so why they have two different names🙄🙄

muneebsohail
Автор

I want to be atmost perfect in java please tell me

Rakesh-nren
welcome to shbcf.ru