Проблемы с быстрой сортировки Итерационный метод C++

Итерационный метод быстрой сортировки выводит 0

#include <iomanip>
#include <random>
#include <cmath>
#include <stack>
using namespace std;

struct Node
{
    int info;
    Node* next = nullptr;
    Node* father = nullptr;
};

void out_results(int**, int**, int, int, int);
bool isTableSorted(int*, int);
bool isTablesEqual(int*, int*, int);
bool isListSorted(Node*);

void create_list(Node*&, int);
void delete_list(Node*&);
int insertion_sort(Node*, int&);
int shell_sort(int*, int, int&);
//int bubble_sort(int*, int, int&);
int quickISort(int* , int , int, int&);
int quick_rec_sort(int*, int, int, int&);
int digital_exchange_sort(int*, int, int&);
int pyramidal_sort(int*, int, int&);
int restore(int*, int, int, int&);
int counting_sort(int*, int, int&);
int merge_sort(int*&, int, int&);
int merge_list_sort(Node*&, int&);

int main()
{
    setlocale(LC_ALL, "rus");

    random_device rd;
    mt19937 gen(rd());

    int N, maxSize, MaxExp, count_of_tables;

    cout << "Введите максимальный размер таблицы: ";
    cin >> maxSize;
    cout << "Введите количество исследуемых размеров таблиц: ";
    cin >> count_of_tables;
    cout << "Введите количество экспериментов: ";
    cin >> MaxExp;
    cout << endl;
    N = maxSize / count_of_tables;

    int** result = new int* [10];
    for (int i = 0; i < 10; i++)
    {
        result[i] = new int[count_of_tables] { 0 };
    }
    int** forwardings = new int* [9];
    for (int i = 0; i < 10; i++)
    {
        forwardings[i] = new int[count_of_tables] { 0 };
    }

    int table_num = 0;
    while (N <= maxSize)
    {
        uniform_int_distribution<> dist1(1, N * 10);
        for (int i = 0; i < MaxExp; i++)
        {
            Node* Head_N = nullptr;
            int* list1 = new int[N] {0};
            int* list2 = new int[N] {0};
            int* list3 = new int[N] {0};
            int* list4 = new int[N] {0};
            int* list5 = new int[N] {0};
            int* list6 = new int[N] {0};
            int* list7 = new int[N] {0};
            int* list8 = new int[N] {0};
            Node* Head_S = nullptr;

            for (int i = 0; i < N; i++)
            {
                int key = dist1(gen);
                create_list(Head_N, key);
                list1[i] = key;
                list2[i] = key;
                list3[i] = key;
                list4[i] = key;
                list5[i] = key;
                list6[i] = key;
                list7[i] = key;
                list8[i] = key;
                create_list(Head_S, key);
            }

            result[0][table_num] += insertion_sort(Head_N, forwardings[0][table_num]);
            result[1][table_num] += shell_sort(list1, N, forwardings[1][table_num]);
        //  result[2][table_num] += bubble_sort(list2, N, forwardings[2][table_num]);
            result[3][table_num] += quickISort(list8, 0 , N, forwardings[3][table_num]);
            result[3][table_num] += quick_rec_sort(list3, 0, N, forwardings[3][table_num]);
            result[4][table_num] += digital_exchange_sort(list4, N, forwardings[4][table_num]);
            result[5][table_num] += pyramidal_sort(list5, N, forwardings[5][table_num]);
            result[6][table_num] += counting_sort(list6, N, forwardings[6][table_num]);
            result[7][table_num] += merge_sort(list7, N, forwardings[7][table_num]);
            result[8][table_num] += merge_list_sort(Head_S, forwardings[8][table_num]);
        //  result[9][table_num] += quickISort(list8, 0 , N, forwardings[9][table_num]);

            delete_list(Head_N);
            delete[] list1;
            delete[] list2;
            delete[] list3;
            delete[] list4;
            delete[] list5;
            delete[] list6;
            delete[] list7;
            delete[] list8;
            delete_list(Head_S);
        }

        N += maxSize / count_of_tables;
        table_num += 1;
    }

    cout << "\n\tРезультаты сортировки:\n\n";
    cout << setw(10) << "N";
    for (int i = maxSize / count_of_tables; i <= maxSize; i += (maxSize / count_of_tables))
    {
        cout << setw(18) << i;
    }
    cout << endl << setw(15) << ' ';
    for (int i = 0; i < count_of_tables; i++)
    {
        cout << setw(9) << "Сравн." << setw(9) << "Перес.";
    }
    cout << endl;
    cout << setw(15) << "Вставками";
    out_results(result, forwardings, count_of_tables, 0, MaxExp);
    cout << setw(15) << "Шелла";
    out_results(result, forwardings, count_of_tables, 1, MaxExp);
    //cout << setw(15) << "Пузырьковая";
    //out_results(result, forwardings, count_of_tables, 2, MaxExp);
    cout << setw(15) << "Быстрая(итер).";
    out_results(result, forwardings, count_of_tables, 2, MaxExp);
    cout << setw(15) << "Быстрая(рек)";
    out_results(result, forwardings, count_of_tables, 3, MaxExp);
    cout << setw(15) << "Цифровая";
    out_results(result, forwardings, count_of_tables, 4, MaxExp);
    cout << setw(15) << "Пирамидальная";
    out_results(result, forwardings, count_of_tables, 5, MaxExp);
    cout << setw(15) << "Подсчетом(пер)";
    out_results(result, forwardings, count_of_tables, 6, MaxExp);
    cout << setw(15) << "Ест. двух. сл.";
    out_results(result, forwardings, count_of_tables, 7, MaxExp);
    cout << setw(15) << "Ест. сл. спис.";
    out_results(result, forwardings, count_of_tables, 8, MaxExp);
    
    
    for (int i = 0; i < 10; i++)
    {
        delete[] result[i];
    }
    delete[] result;
    for (int i = 0; i < 10; i++)
    {
        delete[] forwardings[i];
    }
    delete[] forwardings;

    system("pause");
    return 0;
}

// Вспомогательные функции
// Вывод результата экспериментов и проверка на отсортированность массива
void out_results(int** results, int** forwardings, int exp_num, int alg_num, int MaxExp)
{
    for (int i = 0; i < exp_num; i++)
    {
        cout << setw(9) << results[alg_num][i] / MaxExp << setw(9) << forwardings[alg_num][i] / MaxExp;
    }
    cout << "\n\n";
}
bool isTableSorted(int* list, int N)
{
    for (int k = 0; k < N - 1; k++)
    {
        if (list[k] > list[k + 1])
        {
            return false;
        }
    }
    return true;
}
bool isTablesEqual(int* list1, int* list2, int N)
{
    for (int i = 0; i < N; i++)
    {
        if (list1[i] != list2[i])
            return false;
    }
    return true;
}
bool isListSorted(Node* Head)
{
    while (Head->next != nullptr)
    {
        if (Head->info > (Head->next)->info)
            return false;
        Head = Head->next;
    }
    return true;
}

void create_list(Node*& Head, int key)
{
    // Формирование головы связного списка
    if (Head == nullptr)
    {
        Head = new Node;
        Head->info = key;
        return;
    }
    // Движение по связному списку
    Node* temp = Head;
    while (temp->next != nullptr)
    {
        temp = temp->next;
    }
    // Добавление элемента
    temp->next = new Node;
    (temp->next)->father = temp;
    (temp->next)->info = key;

    return;
}
void delete_list(Node*& Head)
{
    while (Head->next != nullptr)
    {
        Head = Head->next;
        delete Head->father;
    }
    delete Head;
    Head = nullptr;

    return;
}

int quick_rec_sort(int* list, int start, int end, int& forwardings)
{
    int comparisons = 0;
    if (start > end - 1)
        return comparisons;
    int i = start + 1, j = end - 1;

    while (list[i] < list[start])
    {
        comparisons += 1;
        i += 1;
    }
    comparisons += 1;
    while (list[j] > list[start])
    {
        comparisons += 1;
        j -= 1;
    }
    comparisons += 1;

    while (i < j)
    {
        forwardings += 3;
        swap(list[i], list[j]);
        i += 1;
        j -= 1;

        while (list[i] < list[start])
        {
            comparisons += 1;
            i += 1;
        }
        comparisons += 1;
        while (list[j] > list[start])
        {
            comparisons += 1;
            j -= 1;
        }
        comparisons += 1;
    }
    forwardings += 3;
    swap(list[start], list[j]);

    comparisons += quick_rec_sort(list, start, j, forwardings);
    comparisons += quick_rec_sort(list, j + 1, end, forwardings);

    return comparisons;
}


    int quickISort(int* list, int start, int end, int& forwardings)
{
    int comparisons = 0;
    while (start < end)
    {
        int i = start + 1, j = end - 1;

        while (list[i] < list[start])
        {
            comparisons += 1;
            i += 1;
        }
        comparisons += 1;
        while (list[j] > list[start])
        {
            comparisons += 1;
            j -= 1;
        }
        comparisons += 1;

        while (i < j)
        {
            forwardings += 3;
            swap(list[i], list[j]);
            i += 1;
            j -= 1;

            while (list[i] < list[start])
            {
                comparisons += 1;
                i += 1;
            }
            comparisons += 1;
            while (list[j] > list[start])
            {
                comparisons += 1;
                j -= 1;
            }
            comparisons += 1;
        }
        forwardings += 3;
        swap(list[start], list[j]);

        if (j - start > end - j - 1)
        {
            quickISort(list, start, j, forwardings);
            start = j + 1;
        }
        else
        {
            quickISort(list, j + 1, end, forwardings);
            end = j;
        }
    }
    return comparisons;
}```

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