00:01
Hello student, here is the bubble, sort, first how it work.
00:05
So algorithm start from the beginning of the list.
00:07
Compare the first two elements.
00:09
If the first element is greater than the second element, swap them.
00:13
Move to the next pair of the element i .e.
00:15
The second and the third and repeat the comparison and swapping if necessary.
00:19
When the number is greater than do swapping otherwise there is no need.
00:23
Continue this process one pass at a time until no more swaps are needed.
00:27
After each pass the largest unsorted element bubbled up to its the correct position at the end of the list.
00:35
So the correct position will be the end of the list.
00:38
So repeat the process for the remaining unsorted element.
00:41
Now here is an example for the bubble sort in the action.
00:45
Let's we have a list.
00:47
So here the list is 5, 2, 9, 1, 5, 6.
00:54
So these are the element in the bubble in the list.
00:59
So we have to apply bubble sort.
01:03
So here we have to apply the bubble sort.
01:06
So now according to the algorithm first we will do the swapping.
01:11
So do first find out 5 and 2.
01:14
Here we find 5 is greater than 2.
01:17
So here we will do the swapping.
01:20
So here 5 is greater than 2.
01:22
Then do swapping.
01:23
So after swapping the list will become like this.
01:30
2, 5, 9, 1, 5, 6.
01:36
So these will be the element after swapping.
01:38
Now go to the second and third.
01:41
So now second and third will become 5 and 9.
01:45
So here is no need for the swapping as 9 is greater and 5 is smaller.
01:51
So here is no need for swapping.
01:55
Now go to the third and fourth, 9 and 1.
01:59
Here 9 is greater than 1.
02:02
So do swapping.
02:05
So after swapping the list will become like this.
02:13
2, 5, 1, 9, 5, 6...