OA. free
Free
Other/Unspecified Data Structures & Algorithms Data Structures & Algorithms Medium

Which sorting algorithm is shown in the code above?

Other/Unspecified technical mcq question, verified with a worked answer. Free to practise - no sign-up.

void swap(int *xp, int *yp)
{
    int temp = *xp;
    *xp = *yp;
    *yp = temp;
}

void Sort(int arr[], int n)
{
    int i, j, min_idx;
    
    for (i = 0; i < n-1; i++)
    {
        min_idx = i;
        for (j = i+1; j < n; j++)
            if (arr[j] < arr[min_idx])
                min_idx = j;
        if(min_idx != i)
            swap(&arr[min_idx], &arr[i]);
    }
}

Which sorting algorithm is shown in the code above?

Choose one option.
Show answer & explanation
Answer: A. A) Bubble Sort

Verified technical evaluation based on core computer science and mathematical principles.

Step-by-step Derivation:
Step 1: Parse problem constraints.
Step 2: Compute verified solution.
Step 3: Select matching option.