Good code is its own best documentation. As you're about to add a comment, ask yourself, 'How can I improve the code so that this comment isn't needed?' Improve the code and then document it to make it even clearer. Steve McConnell

Bubble sort

Language Java | Level Intermediate | Category Algorithms | August 2, 2015 8:28 pm

Algorithm Problem Description

Bubble sort is a simple sorting algorithm. It compares each item from the array and swap with an adjacent item if they are not in order. The main advantage of bubble sort is an easy implementation. Bubble sort has poor performance and should be avoided in case of a large number of elements in the array.

Write a program to take the un-sorted array and sort the array using bubble sort.



Unsorted array before sorting: [34, 56, 23, 45, 67, 3]
Sorted array After Bubble Sort sorting: [3, 23, 34, 45, 56, 67]



Please login to add comments.