Bubble sort is a sorting algorithm that repeatedly compares adjacent elements and swaps them if they are in the wrong order, with each pass placing the largest unsorted element in its correct position; for an array of n elements, the algorithm requires n-1 passes to complete the sorting process.
Deep Dive
Voraussetzung
- Keine Daten verfügbar.
Nächste Schritte
- Keine Daten verfügbar.
Deep Dive
Bubble Sort considering heights of studentsHinzugefügt:
Last second.
Okay. Now what you do? You stand in decreasing order of your hands.
Last second on the first position.
Last in the middle.
Okay.
We are starting with the double sort and here we are going to sort the elements the accord.
We are having five students standing on the respective positions of the array that is position first position second position third position and fourth position. Now what is the working principle of bubble saw that here two adjacent elements are compared right and whichever is bigger and smaller the swapping takes place over the first element should be smaller than the second one we need to sort these elements in ascending order right so now we will start between the first two adj element that is the zero position element and the first position element.
Now if we see the zero position element the zero position is having a height greater than the first position element first position. So do we have to swap over here?
>> Yes.
Okay.
Now next comparison will take the first position and second position go the height. So we find that the first position door is taller than the second position door. So swapping will take place over here.
Now let us compare the second position door with the third position and we find that the second greater than the third position. So again we have to perform swapping over that.
Now the fourth third position and fourth position will be complete according to their height. They will find that the third position will be having greater than the fourth position again starting will be done. So this was the end of the first pass and at the end of the first pass what did we get? We got the tallest girl on her appropriate position that is the last and we stop the first pass. We got the last girl according to according to her right on the last position.
Right. Now let's start with the second pass. Comparison between these two. Now check the height. Which one is taller and which one is shorter?
She is taller. Second girl is taller.
Second girl is taller.
Second girl is taller. Okay. So swapping will take place over here will take place over here. Now the comparison between these two will be done and will be done.
Now comparison between those two will be done and starting over there and at the end of second pass we got the second tallest girl at her appropriate position. Ready? Now we won't be comparing those two again and again.
Right now let's go to the third pass.
Again the comparison will start from the zero position. Now let's have the comparison between these two and we find that she is taller than the second. So smarting will be done over here.
Okay. Now the next comparison between these two girls will take place. Right?
Now we only comparing that particular girl with the other girls because they have already taken their appropriate position. So to stop the comparison of this particular pass and at the end of third class we got the third tallest girl at her appropriate position. Right now we are left with only two girls and then compare between these two girls. Now let's compare check the heights. Is she taller than the second girl? Yes, she is taller. So starting with this over here, right? We would become very well with the other elements. Whatever those acquired their appropriate position and we stop here and this was our fourth number. Accordingly for n number of elements we are having n minus one number of passes. Here also we consider equals and we completed the sorting in four number of passes. Are they standing in ascending order?
>> Yes.
>> Yes. And here we have performed our song. Ready? How to do it? Yes, everyone. Okay. Thank you so much.
Ähnliche Videos
Agentforce NOW AMA: Build with React and Salesforce Multi-Framework
SalesforceDevs
490 views•2026-05-28
How agent o11y differs from traditional o11y — Phil Hetzel, Braintrust
aiDotEngineer
450 views•2026-05-28
WEB TECHNOLOGIES UNIT-2 | Degree 4th sem BCOM Computers web technologies unit-2 full explanation💯✅
LearnwithSahera
1K views•2026-05-29
More tests are always better? How to use AI to identify tests that bring little value
Alliance4Qualification
335 views•2026-05-29
Search Algorithms Explained in 60 Seconds! 🤖💨
samarthtuliofficial
218 views•2026-06-01
People of Game of Thrones using JavaScript DOM
AltCampus
296 views•2026-05-30
Introduction to Problem Solving Part - 1 | Lecture 1 | Intermediate DSA
ascensionix
107 views•2026-05-29
🚀 BCS613C Compiler Design | Module 1 to 5 Schema Evaluation 🔥 | VTU 6th Sem 💯 #VTU #bcs613c #exam
Pranavaa-y4y
104 views•2026-06-02











