自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(8)
  • 收藏
  • 关注

转载 排序的总结

总结下排序的经验: 排序算法有N多,想全部掌握不太实际,先分类别吧,稳定排序和不稳定排序, 稳定排序包含了:bubble sort(冒泡排序)、insertion sort(插入排序)、merge sort(归并排序)、bucket sort(桶排序)、radix sort(基数排序)、binary tree sort(二叉树排序)、library sort(图书馆排序) 不稳定

2014-02-22 21:56:03 595

原创 排序、查询总结

排序算法分为插入排序、交换排序和选择排序。 插入排序:1、直接插入排序。 将元素一个一个插入到排好序的序列中,空间效率来看仅用了一个辅助单元,时间复杂度为O(n^2)     2、折半插入排序。在获得插入位置时采用二分查找,这样定位插入位置的时间复杂度为O(logN),但找到位置后移动的次数与直接插入排序相同,故时间复杂   度 仍为O(n^2)     3、表插入排序。为了要插入时不移动

2014-02-22 21:06:56 712

原创 二叉排序树的操作_BinaryOrderTree

函数传参时,判断应传入指针还是指针的指针的依据:如果程序中不改变指针本身的值,只改变指针指向的值时传 *;如果程序中会改变指针本身的值则传 ** #include #include #include using namespace std; #define DATATYPE int typedef struct NODE { DATATYPE data; //数据元素字段

2014-02-22 15:29:44 484

原创 折半查找Binary_Search

折半查找的结果:high 比 low 小 1,插入的位置为 high + 1 #include #include int BinarySearch(int data[], int length, int key) { int flag = -1; int low = 0, high = 9; while(low <= high) { int middle = (low + hi

2014-02-20 22:26:15 482

原创 快速排序_quick_sort

#include #include #include using namespace std; /* 交换两个数 */ void exchange(int &x, int &y) { int temp = x; x = y; y = temp; } /* 将数组data中的[left, right]中的数据以data[right]为界划分为左右两部分 */ int parti

2014-02-20 22:23:05 506

原创 堆排序_heap_sort

#include #include #include using namespace std; class DataType:public vector { public: int heapSize; DataType():heapSize(0){}; ~DataType(){}; protected: private: }; /* 将index为结点的子树调整为最大堆,保持

2014-02-15 09:55:27 488

原创 合并排序_merge_sort

#include #include #include #define ARRAY_LEN 16 #define START 0 #define END 15 using std::vector; void Merge(int *data, const int start, const int middle, const int end) { //求前后两段数组的长度 const in

2014-02-13 18:37:11 598

原创 插入排序 insertion_sort

#include #include #define ARRAY_LEN 9int main(){int data[] = {23,4,12,65,32,5,24,544,324}; for (int i = 1; i = 0 && data[j] > key) //依次比较{data[j + 1] = data[j];j--;}data[j + 1] = key; //插入正确的位置}for(

2014-02-13 11:43:36 443

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除