# 数据结构 **Repository Path**: KaiFeng10086/algorithm ## Basic Information - **Project Name**: 数据结构 - **Description**: 记录算法的学习过程,以C++为主 - **Primary Language**: C++ - **License**: MulanPSL-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2024-08-25 - **Last Updated**: 2024-08-31 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 数据结构 #### 介绍 记录算法的学习过程,以C++为主 # Python ## 1.基础 **Python的`int`类型**: Python 中的 `int` 类型是任意精度的整数类型,不存在位数限制 # C++ 时间:10^8 ## 1.基础 - ### 质因子 ```c++ for (int j = 2; j < n/j ; j++) ``` `n/i`(`i <= sqrt(n)`) - ### 输入输出 在C++中,是没有格式符的,我们可以通过使用==setprecision()==函数来实现这个需求 想要使用 setprecision() 函数,必须包含头文件#include ,使用方式如下 ```c++ cout << "a=" << setprecision(2) << a <> ii >> jj >> xx >> yy; double tempx = xx * (kk[jj]/kk[ii - 1]); double tempy = yy * (kk[jj]/kk[ii - 1]); xx = tempx * cos(ee[jj] - ee[ii - 1]) - tempy * sin(ee[jj]- ee[ii - 1]); yy = tempx * sin(ee[jj] - ee[ii - 1]) + tempy * cos(ee[jj]- ee[ii - 1]); printf("%lf %lf\n", xx, yy); } ``` > 注意: > > `kk[jj]/kk[ii - 1]` > > `ee[jj]- ee[ii - 1]` ## 4.vector - ### vector定义二维数组, resize方法 ```c++ vector > ls; ls.resize(n + 1); for (int i = 0; i < n; i ++ ){ ls[i] = vector(); } ``` - ### vector初始化 ```c++ vector> arr(m, vector(n)); //动态开辟m*n的二维数组,并初始化为0 vector> arr(m, vector(n, 1)); //动态开辟m*n的二维数组,并初始化为0 vector> arr; arr.resize(m, vector(n)); //采用resize进行初始化 ``` ## 5.\#include - fixed << setprecision(3) ```C++ cout << fixed << setprecision(3) << (x * cos(sum_xita) - y * sin(sum_xita)) * pro_k << " "<< (x * sin(sum_xita) + y * cos(sum_xita)) * pro_k << endl; ``` # 习题 ## 第五章 数组、 广义表 ### 5.1 ![image-20240610203316954](C:\Users\86137\AppData\Roaming\Typora\typora-user-images\image-20240610203316954.png) (1) 6×8×6=288 Byte (2) LOC(5,7)=1000+(5×8+7)×6=1282 (3) LOC(1,4)=1000+(1×8+4)×6=1072 (4) LOC(4,7)=1000+(7×6+4)×6=1276 ### 5.2 ![image-20240610203343112](C:\Users\86137\AppData\Roaming\Typora\typora-user-images\image-20240610203343112.png) ![image-20240610203525402](C:\Users\86137\AppData\Roaming\Typora\typora-user-images\image-20240610203525402.png) # 数据结构 成绩构成 - 作业5, 上课5, 实验20, 考试70 ## 时间复杂度 ![image-20240412174542259](C:\Users\86137\AppData\Roaming\Typora\typora-user-images\image-20240412174542259.png) ## A*算法 ![image-20240409115436125](C:\Users\86137\AppData\Roaming\Typora\typora-user-images\image-20240409115436125.png) ## 递归&递推 # 树 树的深度(高度)、 结点的**层次** image-20240423144242092 ## 二叉树 ### 小根堆 ### 大根堆 ### 线索二叉树 ![image-20240611135259691](C:\Users\86137\AppData\Roaming\Typora\typora-user-images\image-20240611135259691.png) ![image-20240611140837101](C:\Users\86137\AppData\Roaming\Typora\typora-user-images\image-20240611140837101.png) ## 完全二叉树 ## 满二叉树 ## 二叉排序树 ## 平衡二叉树 # 图 完全图、有向完全图: ![image-20240521133551428](C:\Users\86137\AppData\Roaming\Typora\typora-user-images\image-20240521133551428.png) 稠密图、稀疏图 ![image-20240521133607270](C:\Users\86137\AppData\Roaming\Typora\typora-user-images\image-20240521133607270.png) ## 存储 邻接表 邻接矩阵 稀疏图 稠密图 关节点 -- ## 拓扑排序: ![image-20240507144349706](C:\Users\86137\AppData\Roaming\Typora\typora-user-images\image-20240507144349706.png) ## 关键路径: 关键活动 最早发生时间:ve 最迟发生时间: vl # other ## 并查集 ## 逆序对 下标小--对应数也小 下标大 -- 对应数小 -- 逆序对 -- 归并排序