Bubble
Bubble
i) Repeat the following steps for each element in the array, starting from the
beginning:
a) For each element up to the second-to-last unsorted element, compare it with the
next element:
- If the current element is greater than the next element, swap them.
b) After each pass, the largest unsorted element will have "bubbled up" to its correct
position, so reduce the range of elements to be checked in the next pass.
ii) Continue this process until no swaps are needed in a pass, indicating that the
array is fully sorted.
#include <stdio.h>
int i, j;
arr[j + 1] = temp;
int main() {
bubblesort(arr, n);
return 0;
OUTPUT
Sorted array: 11 12 22 25 34 64 90