Bubble sort is the most simple sorting technique used to sort arrays , linked list etc. It is an algorithm that keeps traversing the list until the list is completly sorted. Bubble sort has been occasionally referred to as a "sinking sort". The idea being that the larger elements are heavier hence they sink to the bottom of the list and smaller elements being light bubble to the top of the list.
Algorithm
In bubble we keep comparing 2 adjacent elements and swap their places is they are not in correct order.
Performance
Bubble sort being a simple algorithm works fine when the size of the data is small but its performance decreases as the size of the data increases, hence Bubble is used only when number of elements is small or only some elements are out of order.
To know more about bubble sort, its performance, complexity and comparisons to other sorting methods click Here.
You might Also be interested in
Stack implementation using Linked List
Queue implementation using Linked List
Linked List in Java
Linked List in c++
Binary Search Tree
Height of Binary Search Tree
Algorithm
In bubble we keep comparing 2 adjacent elements and swap their places is they are not in correct order.
Performance
Bubble sort being a simple algorithm works fine when the size of the data is small but its performance decreases as the size of the data increases, hence Bubble is used only when number of elements is small or only some elements are out of order.
To know more about bubble sort, its performance, complexity and comparisons to other sorting methods click Here.
C Program
C++ Program
Sample input and output to check the program
You might Also be interested in
Stack implementation using Linked List
Queue implementation using Linked List
Linked List in Java
Linked List in c++
Binary Search Tree
Height of Binary Search Tree
Comments
Post a Comment