这篇文章主要介绍了C++中的几种排序算法,需要的朋友可以参考下
SortAlgorithm.h
代码如下:
#include
using namespace std;
using namespace std;
class SortAlgorithm
{
public:
SortAlgorithm(int = 10);
void displayVector();
void swap(int &, int &);
void insertSort(); //O(n^2)
void selectSort(); //O(n^2)
void mergeSort(); //O(n log n)
void bubbleSort(); //O(n^2)
void quickSort( int , int ); //worst: O(n^2), best: O(n log n)
int partition( int , int );
void sortSubVector(int , int );
来源gaodai#ma#com搞*代#码网 void merge(int , int , int , int );
private:
int size;
vector source;
vector temp;
};
以上就是C++中的几种排序算法的详细内容,更多请关注gaodaima搞代码网其它相关文章!