Bubble SortIn Bubble sort, Each element of the array is compared with its adjacent element. The algorithm processes the list in passes. A list with n elements requires n-1 passes for sorting. Consider an array A of n elements whose elements are to be sorted by using Bubble sort. The algorithm processes like following.
Algorithm :
Complexity
C ProgramOutput: Printing Sorted Element List . . . 7 9 10 12 23 34 34 44 78 101 C++ ProgramOutput: Printing Sorted Element List ... 7 9 10 12 23 23 34 44 78 101 Java ProgramOutput: Printing Sorted List . . . 7 9 10 12 23 34 34 44 78 101 C# ProgramOutput: Printing Sorted Element List . . . 7 9 10 12 23 34 34 44 78 101 Python ProgramOutput: Printing Sorted Element List . . . 7 9 10 12 23 34 34 44 78 101 Rust ProgramOutput: Printing Sorted Element List . . . 7 9 10 12 23 34 34 44 78 101 4 JavaScript ProgramOutput: Printing Sorted Element List ... 7 9 10 12 23 23 34 44 78 101 PHP ProgramOutput: Printing Sorted Element List ... 7 9 10 12 23 23 34 44 78 101
Next TopicBucket Sort
|