![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
数据结构与算法
山海入怀
这个作者很懒,什么都没留下…
展开
-
八大排序所花时间测试序列(线性复杂度居然干不过log复杂度?)(采用的C++,结构体排序)
首先是测试前准备整体思路:生成1000个随机的字符串,如果字符串相同长度,就按字典序从小到大,否则,按照字符串长度从小到大排序,对于每一种方法,都用clock()函数记录总体时间,最后进行汇总首先是代码准备:#include<iostream>#include<string>#include<vector>#include<time.h>#include<algorithm>#include<map>#include原创 2021-03-31 19:19:40 · 1143 阅读 · 2 评论 -
大顶堆的插入和删除(C语言)
#include<stdio.h>#include<math.h>#include<stdlib.h>#include<time.h>const int MAXN = 10000;struct Data{ int id = 0;};struct Heap{ Data data[MAXN]; int size; Heap() { data[0].id = _CRT_INT_MAX; size = 0; }};void I原创 2021-03-26 23:20:04 · 631 阅读 · 0 评论 -
二叉搜索树的插入和删除(附带随机数测试)(C语言实现)
#include<stdio.h>#include<stdlib.h>#include<time.h>struct Data{ int id;};struct STree{ Data data; STree* left; STree* right;}*head= NULL;void travel(STree* now, Data data);void insert(STree** head, Data data);STree* find_m原创 2021-03-26 21:06:35 · 301 阅读 · 0 评论 -
完全二叉树的生成,以及前中后序遍历(递归或者非递归都有)(C++类实现)
#include<stdio.h>#include<stdlib.h>#include<stack>#include<queue>using namespace std;struct Data{ int id;};struct Node{ Data data;//数据 bool isprint = 0;//后序非递归判断是否被打印 Node* left;//左孩子 Node* right;//右孩子 Node* prev;//父亲原创 2021-03-26 16:06:08 · 122 阅读 · 0 评论 -
基于随机数的二分查找(C语言+stl实现)
#include<stdio.h>#include<stdlib.h>#include<time.h>#include<algorithm>using namespace std;const int MAXN = 10000;int a[MAXN - 1];int main(){ srand(time(0)); //给a数组赋予MAXN个随机数 for (int i = 0; i <= MAXN - 1; i++) { a原创 2021-03-24 21:46:15 · 339 阅读 · 0 评论 -
多项式相加队列法(附带队列的链式存储实现)
#include<stdio.h>#include<stdlib.h>struct Data{ double ratio;//系数 int index;//指数};struct Node{ Data data; Node* next;};Node* head1 = NULL;Node* head2 = NULL;Node* headsum = NULL;struct QNode{ Node* front; Node* rear; };void原创 2021-03-24 21:09:38 · 225 阅读 · 0 评论 -
队列的链式存储(C语言+一点点C++实现)
#include<stdio.h>#include<stdlib.h>struct Data{ int id;};struct Node{ Data data; Node* next;};Node* head = NULL;struct QNode{ Node* front; Node* rear; };void in_quene(QNode* quene, Data data);Data* out_quene(QNode* quene);in原创 2021-03-24 20:17:59 · 72 阅读 · 0 评论 -
统计单词个数并排序(C with stl)
#include<stdio.h>#include<string.h>#include<stdlib.h>#include<algorithm>using namespace std;const int MAXN = 2000000;//文章的最大字符数const int MAXW = 20;//单词的最大字符数bool isletter(char c);struct Word{ char word[MAXW]; int n;}wor原创 2021-03-24 17:13:37 · 355 阅读 · 0 评论 -
中缀表达式转后缀表达式(C with stl)
```cpp#include<iostream>#include<stdio.h>#include<string.h>#include<map>#include<string>using namespace std;struct Data{ char sym;};struct Stack{ Data data; Stack* next;};bool pop_stack(Data data, Stack** T.原创 2021-03-24 17:02:42 · 446 阅读 · 0 评论