почему при минимальной формуле количества перестановок в программе гораздо меньше

Например есть метод выбора вот для него формула перестановок (действий): min:3(n-1),max:1/4*n^2+3(n-1),n-количество элементов.В программе получается 9 а в формуле с минимальным 27 с максимальным 52,это при 10 элементах.

#include <iostream> 
#include <cstdlib> 
#include <time.h> 
#define N 10
using namespace std;
 
void print(int arr[], int size)
{
    for (int i = 0; i < size; i++)
        cout << arr[i] << " ";
    cout << endl;
}
 
int main() {
    srand(time(NULL));
 
    int array[N];
    for (int i = 0; i < N; i++) {
        array[i] = 12 + rand();
        cout << array[i] << " ";
    }
    cout << endl;
 
    int swaps = 0, compares = 0;
 
    for (int startIndex = 0; startIndex < N - 1; ++startIndex)
    {
 
        int smallestIndex = startIndex;
 
        for (int currentIndex = startIndex + 1; currentIndex < N; ++currentIndex)
        {
            compares++;
            if (array[currentIndex] < array[smallestIndex])
 
                smallestIndex = currentIndex;
        }
 
        swaps++;
        swap(array[startIndex], array[smallestIndex]);
        cout << "swap #" << swaps << ": ";
        print(array, N);
    }
    cout << "Sorted massiv" << endl;
    print(array, N);
 
    cout << "\nswaps: " << swaps << "\ncompares: " << compares;
 
    return 0;
 
}

Ответы (0 шт):