- 博客(11)
- 收藏
- 关注
原创 二叉搜索树
#include <bits/stdc++.h> using namespace std; template<class T> class binaryTree { private: typedef struct treeNode { T val; struct treeNode *ls, *rs; } node; .
2022-05-27 12:01:45
131
原创 优先队列(二叉堆)
``` #include <iostream> using namespace std; template<class T, const int MAX_SIZE> class priority_queue { private: T _node[MAX_SIZE]; int _idx = 1; /* * the ...
2022-05-27 11:56:29
126
原创 哈夫曼树 & 八皇后
文章目录哈夫曼树八皇后 哈夫曼树 这里使用优先队列(小根堆)进行构建,并且使用查探法在数组中寻找新建结点的位置。 输入一个字符串, 输出它的哈夫曼编码 #include <bits/stdc++.h> #define remilia int #define isMyWife main using namespace std; const int N = 10000; // 记录权值 int times[30], n, index = 30; int val[N], ls[N], rs[
2022-05-26 23:58:56
169
原创 二叉树及其遍历
文章目录递归非递归 递归 void preOrder(int root) { if (!val[root]) { return; } cout << val[root] << " "; preOrder(ls[root]); preOrder(rs[root]); } void inOrder(int root) { if (!val[root]) { return; } inOrder(ls[root]); cout << val[r
2022-05-24 23:30:15
132
原创 矩阵乘法 & 二维数组 & 压缩矩阵
文章目录代码结果 代码 import kotlin.time.measureTime /** * */ class Matrix() { /** * 矩阵的行的数量 * 不允许更改, 只能在初始化的时候设置 */ private var rows: Int = 0 /** * 矩阵列的数量 * 不允许更改, 只能在初始化的时候设置 */ private var columns: Int = 0 /*
2022-05-19 23:21:45
253
原创 数据结构 - 队列
文章目录老师代码接口定义数据定义链式队列循环队列 队列是一种后进后出的结构 老师代码 循环 #include <stdio.h> #include <malloc.h> #define TOTAL_SPACE 5 /** * Circle int queue. */ typedef struct CircleIntQueue{ int data[TOTAL_SPACE]; int head; int tail; }*CircleIntQueuePtr; /**
2022-05-17 22:49:18
351
原创 栈和栈的应用
文章目录栈栈的应用括号匹配表达式求值 栈 栈是一个符合先进先出的结构, 首先呈上老师的代码 #include <stdio.h> #include <malloc.h> #define STACK_MAX_SIZE 10 /** * Linear stack of integers. The key is data. */ typedef struct CharStack { int top; int data[STACK_MAX_SIZE]; //The
2022-05-10 22:45:24
185
2
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅