What is Bubble sort and example In C++
In this program we will write a program which sorts an array of numbers using a famous bubble sort algorithm. This algorithm uses a “swap” function which swaps values stored in two memory locations with each other. Bubble sort compares each two cells of the array and if they are not in correct order, it swaps them. If we need the array to be sorted in ascending order, each cell should be bigger or equal to previous cell and the first cell should be smaller than any other cell. If we perform these compares and swaps for “n- 1” times on the entire array, our array will be completely sorted.
Bubble sort example In C++
© 2016-2019, Codeverb.com - All Rights Reserved