I had an argument with a friend about the real bubble sort of the following two algorithms, and about which one is better, no mention which one is mine, I just want to hear your answers on these two questions about those two algorithms (written in c++)
1-which one is the real bubble sort?
2-which one is better?
here are the two algorithms :
// Number one :
void BubbleSort(int Arr[], int size)
{ for (int i=0;i<size-1;i++)
for (int j=i+1;j<size;j++)
if (Arr[i]>Arr[j])
{ int temp = Arr[i];
Arr[i] = Arr[j];
Arr[j] = temp;
} }
// Number two :
void BubbleSort(int Arr[], int size)
{ for (int i=0;i<size-1;i++)
for (int j=0;j<size-1;j++)
if (Arr[j]>Arr[j+1])
{ int temp = Arr[j];
Arr[j] = Arr[j+1];
Arr[j+1] = temp;
} }