(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
Bubble sort | Data structure |
1. SUBMITTED BY :
Name : Saiful Islam
Institute: Green University Of Bd
ID : 162-015-022
Batch : 162
1
2. What is bubble sort :
Bubble short is A simple sorting algorithm. This sorting algorithm is
comparison based algorithm in which each pair of adjacent elements is
compared and elements are swapped if they are not in order . this
algorithm is not suitable for large data sets as its average and worst case
complexity are of 0(n2) where n are no. Of items.
2
3. How bubble sort works?
We take an unsorted array for our example. Bubble sort take 0(n2) time so
we’re keeping short and precise.
3
4. Sorting :
In this case, value 33 is greater than 14, so it is already in sorted locations.
Next, we compare 33 with 27
Bubble sort starts with very first two elements, comparing them to check
which one is greater.
4
5. Sorting :
The new array should look like this -
We find that 27 is smaller than 33 and these two values must be swapped.
5
6. Sorting :
Next we compare 33 and 35. We find that both are in already sorted
position.
Then we move to next two values, 35 and 10.
We know than 10 is smaller 35. Hence they are not sorted.
6
7. Sorting second time :
First sort
Second sort
Third sort
Fourth sort
Now we should look into same practical aspects of bubble sort.
7
8. Advantages :
It does not deal well with a list containing a huge number of
items.
More than the number of comparisons.
The code become complex for large amount of data.
Disadvantages :
Bubble sort is one of the easiest sort algorithm.
It is easy to implement.
Elements are swapped in place, not use extra array.
It is stable and fast.
8