Michele La Ferla
Michele La Ferla

Reputation: 6884

Integer Sorting Algorithms

I would like to know what kind of sorting algorithm is the one below. I understand that it is a integer sorting algorithm but other than that I haven't figured it out:

void mySorter(int arr[]) {
    int a = arr.length;

    for (int i = 0; i < a-1; i++) {
        int min = i;

        for (int j = i +1 ; j < a; j++) {
            if (arr[j] < arr[min])
                min = j;
            int temp = arr[min];
            arr[min] = arr[i]
            arr[i] = temp;
        }
    }     
}

Could it be a selection sort?

Upvotes: 0

Views: 55

Answers (1)

satya sai
satya sai

Reputation: 46

It is Bubble Sort. Your code sorts the list in ascending order.

Upvotes: 1

Related Questions