bubble sort program in cpp data structure code example
Example: code for bubble sort in c++
void bubbleSort (int S[ ], int length) {
bool isSorted = false;
while(!isSorted)
{
isSorted = true;
for(int i = 0; i<length; i++)
{
if(S[i] > S[i+1])
{
int temp = S[i];
S[i] = S[i+1];
S[i+1] = temp;
isSorted = false;
}
}
length--;
}
}