DSU 313301 Practical No.6: Write a ‘C’ Program to Sort an Array of numbers using Bubble Sort Method
Bubble sort is one of the simplest sorting algorithms that works by repeatedly stepping through the list to be sorted, comparing each pair of adjacent items, and swapping them if they are in the wrong order. This process is repeated until no swaps are needed, which indicates that the list is sorted.
Algorithm
C Program Code
Result (Output of Program)
Unsorted array:
64 34 25 12 22 11 90
Sorted array:
11 12 22 25 34 64 90
Practical Related Questions
1. Optimize the Bubble Sort algorithm to stop early if the array is already sorted.
Answer:
2. Modify the Bubble Sort algorithm to sort an array in descending order.
Answer:
Exercise
1. Enlist Applications of Bubble Sort.
Answer:
2. Explain why Bubble sort is called as stable Sort.
Answer:
Conclusion
We successfully completed DSU 313301 Practical No.6 and Wrote a ‘C’ Program to Sort an Array of numbers using Bubble Sort Method.