摘要: #include using namespace std; class ShellSort { public: int* shellSort(int* A, int n) { // write code here for(int gap = n / 2; gap > 0; gap /= 2){ for(int index_beg... 阅读全文
posted @ 2016-08-20 19:39 zhongzhiqiangZz 阅读(122) 评论(0) 推荐(0) 编辑
摘要: #include using namespace std; class SelectionSort { public: int* selectionSort(int* A, int n) { if(n == 1) return A; int tmp, index; for(int index_sorted = 0... 阅读全文
posted @ 2016-08-20 19:38 zhongzhiqiangZz 阅读(126) 评论(0) 推荐(0) 编辑
摘要: #include #include #include #include #include using namespace std; class RadixSort { public: int* radixSort(int* A, int n) { // write code here //because value is smaller tha... 阅读全文
posted @ 2016-08-20 19:37 zhongzhiqiangZz 阅读(184) 评论(0) 推荐(0) 编辑
摘要: #include using namespace std; class QuickSort { public: int* quickSort(int* A, int n) { quickSortRecursive(A, 0, n - 1); return A; } void quickSortRecursive(int* A, int ... 阅读全文
posted @ 2016-08-20 19:36 zhongzhiqiangZz 阅读(109) 评论(0) 推荐(0) 编辑
摘要: #include using namespace std; class MergeSort { public: int* mergeSort(int* A, int n) { mergeSortRecursive(A, 0, n); return A; } void mergeSortRecursive(int* A, int inde... 阅读全文
posted @ 2016-08-20 19:35 zhongzhiqiangZz 阅读(156) 评论(0) 推荐(0) 编辑
摘要: #include using namespace std; class InsertionSort { public: int* insertionSort(int* A, int n) { // write code here int tmp; int index_insert; for(int index = 1; ... 阅读全文
posted @ 2016-08-20 19:34 zhongzhiqiangZz 阅读(99) 评论(0) 推荐(0) 编辑
摘要: #include using namespace std; class HeapSort { public: int* heapSort(int* A, int n) { buildMaxHeap(A, n); int tmp; for(int i = n-1; i >0; i--){ tmp = A[0];... 阅读全文
posted @ 2016-08-20 19:33 zhongzhiqiangZz 阅读(167) 评论(0) 推荐(0) 编辑
摘要: #include #include #include using namespace std; class CountingSort { public: int* countingSort(int* A, int n) { // write code here int* counting = new int[1000]; int* ... 阅读全文
posted @ 2016-08-20 19:31 zhongzhiqiangZz 阅读(104) 评论(0) 推荐(0) 编辑
摘要: #include using namespace std; class BubbleSort { public: int* bubbleSort(int* A, int n) { // write code here int tmp; for(int index_max = n - 1; index_max >=0; index_max... 阅读全文
posted @ 2016-08-20 19:29 zhongzhiqiangZz 阅读(132) 评论(0) 推荐(0) 编辑
摘要: #include #include #include using namespace std; struct TreeNode { int val; struct TreeNode *left; struct TreeNode *right; TreeNode(int x) : val(x), left(NULL), right(N... 阅读全文
posted @ 2016-08-20 19:27 zhongzhiqiangZz 阅读(130) 评论(0) 推荐(0) 编辑