comprecpp/cppbase/algorithm/CAlgorithm.h

119 lines
3.6 KiB
C
Raw Normal View History

2024-03-08 15:25:16 +08:00
//
// Created by TYP on 2023/9/2.
//
#ifndef COMPRE_CALGORITHM_H
#define COMPRE_CALGORITHM_H
#include <cstdio>
void PrintArrayInt(const int array[], int nCnt)
{
if (nCnt < 1)
return ;
for (int i = 0; i < nCnt; ++i)
std::printf("%d ", array[i]);
printf("\n");
}
class CAlgorithm {
public:
CAlgorithm() = default;
~CAlgorithm() = default;
public:
/*
* 1.
*
* ``
* O(n^2)
* O(1)
* i a[i]~a[n]
* i i
*
*
* https://blog.csdn.net/u011815404/article/details/79256237
*/
static void SortDirectSelectMethod(int array[], int nSize);
/*
* 2.
*
*
* O(n^2),O(nlogn);O(nlogn);
* O(logn)
*
*
*
*
*
* https://blog.csdn.net/weixin_61453872/article/details/121481223
*/
static void SortQuickMethod(int array[], int nStartIndex, int nEndIndex);
/*
* 3.
*
*
* O(n^2)
* O(1)
*
*
*/
static void SortBubbleMethord(int array[], int nSize);
/*
* 4.
*
*
*
* O(nlogn)
* o(n)
* img/.png
*/
/*
* 5.
*
*
* O(n^2)
* O(1)
*/
/*
* 6.
*
*
* O(n^(1.32))
* O(1)
* img/.jpeg
*/
/*
* 7.
*
*
* O(nlogn)
* O(1)
*/
/*
* 8.
*
*
* O(n^2)
* O(1)
* ...
*/
};
// 直接排序测试
void SortDirectSelectMethodTest();
// 快速排序测试
void SortQuickMethodTest();
// 冒泡排序测试
void SortBubbleMethordTest();
#endif //COMPRE_CALGORITHM_H