随笔分类 -  课程 / 算法与数据结构

摘要:1.二叉查找树 或 二叉排序树 (BST) 性质:左子树的键值小于根的键值,右子树的键值大于根的键值。 2.平衡二叉树(AVL Tree) 它是一棵空树或它的左右两个子树的高度差的绝对值不超过1,并且左右两个子树都是一棵平衡二叉树。 在AVL树中增删节点会导致AVL树失去平衡,有四种情况:LL,LR 阅读全文
posted @ 2019-10-10 11:33 赵钱富贵 阅读(376) 评论(0) 推荐(0)
摘要:1.分治策略在于将一个问题分成若干个小问题,问题本身不变只是规模更小 阅读全文
posted @ 2019-06-05 22:10 赵钱富贵 阅读(251) 评论(0) 推荐(0)
摘要:数据结构可以表示为一个四元组(D,L,S,O) data relative logic operation data:所要组织和操作的数据 logic: 线性关系、树形关系、图形关系、集合关系 storage: 顺序存储、链式存储 operation: 查找、添加、删除、遍历、排序... 阅读全文
posted @ 2019-05-21 15:18 赵钱富贵 阅读(136) 评论(0) 推荐(0)
摘要:以行优先顺序存储的三维数组A[m][n][k], 其中元素A[0][0][0]的地址为a, 且每个元素占b个字节, 则A[x][y][z]的地址为 a+(x*n*k+y*k+z)*b, 将m,n,k,视为z,y,x轴 , 阅读全文
posted @ 2019-04-14 10:58 赵钱富贵 阅读(2027) 评论(0) 推荐(0)
摘要:#define MaxSize 100 class SeqList{ private: int a[MaxSize]; int length; public: SeqList(){ length=0; } int insert(int i,int x); int del(int i); int re 阅读全文
posted @ 2019-03-25 13:32 赵钱富贵 阅读(127) 评论(0) 推荐(0)
摘要:using namespace std; struct LNode{ char data; LNode *next; }; class LinkList{ private: LNode *head; public: LNode *createLinkListHead();//头插法创建 LNode 阅读全文
posted @ 2019-03-24 19:14 赵钱富贵 阅读(207) 评论(0) 推荐(0)
摘要:void swap(int *a,int *b){ int temp=*a; *a=*b; *b=temp; } void quickSort(int *a,int left,int right){ if(left>right) return; int temp=a[left]; int i=left; int j=right; while(i!=j){ while... 阅读全文
posted @ 2019-03-22 17:31 赵钱富贵 阅读(157) 评论(0) 推荐(0)
摘要:void merge1(int *a,int left,int mid,int right){ int n1=mid-left+1; int n2=right-mid; int *arr1=new int[n1]; int *arr2=new int[n2]; for(int i=0;i<n1;i++) arr1[i]=a[left+i]; for(int i=0;i<n2;i+... 阅读全文
posted @ 2019-03-22 10:16 赵钱富贵 阅读(273) 评论(0) 推荐(0)
摘要:void swap(int *a,int *b){ int temp=*a; *a=*b; *b=temp; } void BubbleSort(int *a,int length){ for(int i=0;ia[j+1]) swap(a+j,a+j+1); } } } 阅读全文
posted @ 2019-03-21 22:36 赵钱富贵 阅读(95) 评论(0) 推荐(0)
摘要:常用的内部排序方法有:交换排序(冒泡排序、快速排序)、选择排序(简单选择排序、堆排序)、插入排序(直接插入排序、希尔排序)、归并排序、基数排序(一关键字、多关键字)。 一、冒泡排序: 1.基本思想: 两两比较待排序数据元素的大小,发现两个数据元素的次序相反时即进行交换,直到没有反序的数据元素为止。 阅读全文
posted @ 2019-03-20 12:41 赵钱富贵 阅读(958) 评论(0) 推荐(1)
摘要:void swap(int *a,int *b){ int temp=*a; *a=*b; *b=temp; } void selectSort(int *a,int n){ for(int i=0;i<n-1;i++){ int min=i; for(int j=i+1;j<n;j++){ if( 阅读全文
posted @ 2019-03-20 12:15 赵钱富贵 阅读(105) 评论(0) 推荐(0)
摘要:void insertionSort(int *a,int n){ for(int i=1;i=0&&a[j]>key){ a[j+1]=a[j]; j--; } a[j+1]=key; } } 阅读全文
posted @ 2019-03-20 08:20 赵钱富贵 阅读(70) 评论(0) 推荐(0)
摘要:void ShellSort(int *a,int length){ int gap=length/2; while(gap>=1){ //插入排序思想 gap替换1 for(int i=gap;i=0&&a[j]>temp){ a[j+gap]=a[j]; j=j-gap; } a[j+gap]=temp; } gap... 阅读全文
posted @ 2019-03-15 17:31 赵钱富贵 阅读(90) 评论(0) 推荐(0)