#include
#include
#define NUM_ITEMS 1000
void bubbleSort(int numbers[],int array_size);
int numbers[NUM_ITEMS];
int counter;
int main()
{
srand(getpid());//fill array with random integers
for (i = 0;i <NUM_ITEMS;i++)
numbers[i] = rand();
bubbleSort(numbers,NUM_ITEMS);//perform bubble sort on array
for (i = 0;i <NUM_ITEMS;i++)
printf(“%i\n”,numbers[i]);
printf(“Done with sort.\n”);
printf(“%i %i\n”,i,counter);
}
void bubbleSort(int numbers[],int array_size)
{
int i,j,temp;
for (i = (array_size –1);i >= 0;i–)
{
for (j = 1;j <= i;j++)
{
if (numbers[j-1] >numbers[j])
{
temp = numbers[j-1];
numbers[j-1] = numbers[j];
numbers[j] = temp;
}
counter++;
}
counter++;
}
}
Inlinks:
- Data Security
- MD5 and SHA-1 ( Hash Function Chryptography )
- Apa itu Algorithms?
- SORTING ALGORITHM #1
- SORTING ALGORITHM ANALYSIS
- Sejarah Kriptografi
- Keamanan Informasi dan Kriptografi
- Quick-sort Source-Code
- Merge-sort Source-Code
- Insertion-sort Source-Code
- Selection-sort Source-Code
- Heap-sort Source-Code
- Bubble-sort Source-Code
- Enkripsi RC4 part 2
- Matrix-Chain-Multiply Source-Code
- Matrix-Chain-Order
- LINEAR DISCRIMINANT ANALYSIS (LDA)
