Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void bubbleSort(int list[], int size)
- {
- int help;
- for(int i=0;i<size;i++)
- {
- for(int j=0;j<size;j++)
- {
- if(list[j+1] < list[j])
- {
- help = list[j+1];
- list[j+1] = list[j];
- list[j]=help;
- }
- }
- }
- }
- void insertionSort(int list[], int size){
- int help;
- for(int i=0;i<size;i++)
- {
- int j = i + 1;
- help = list[j];
- while(j > 0 && help < list[j-1])
- {
- list[j] = list[j-1];
- j--;
- }
- list[j] = help;
- }
- }
- void selectionSort(int list[], int size)
- {
- int help;
- for(int i = 0; i < size; i++)
- {
- int maxIndex = i;
- for(int j=i+1; j < size; j++)
- {
- if(list[j] < list[maxIndex])
- {
- maxIndex =j;
- }
- }
- help = list[i];
- list[i] = list[maxIndex];
- list[maxIndex] = help;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement