数据结构
洛三岁
但为君故
展开
-
用自定义的栈实现算术表达式(后缀表达式)求值
用自定义的栈实现算术表达式求值 基本思想就是把中缀表达式通过栈转换为后缀表达式,然后利用后缀表达式求值。当然可以换成STL里的栈。但如果都用STL了还学什么数据结构嘛。看不懂留言。 #include <iostream> #include <string> using namespace std; #define max 88 //luosansui's Sequential stack //构建一个栈的数据类型 struct stack { string* m_sq = new原创 2020-12-09 17:47:14 · 349 阅读 · 0 评论 -
哈夫曼树及哈夫曼编码(哈夫曼编码为string实现)
哈夫曼树及哈夫曼编码(哈夫曼编码为string实现) #include<iostream> #include<string> #include <algorithm> using namespace std; //luosansui struct Huffman{ int weight; int father; int left; int right; char tip; Huffman() { weight = 0; father = 0; le原创 2020-12-09 17:41:16 · 170 阅读 · 0 评论 -
KMP算法string实现
KMP算法实现 (1)查到即退出 #include <iostream> using namespace std; #include<string> //luosansui KMP void getmax(const string& str, string& a, int& m_next, int sonPos = 0) { //获取最大公共前后缀 //获取字串不匹配位次 int index = 0; int flag = 0; int len =原创 2020-12-09 16:06:25 · 262 阅读 · 0 评论 -
二叉排序/搜索树类模板
二叉排序树模板模板类测试主函数调用 By luosansui 模板类 将整个二叉排序树封装为一个模板类 #include <iostream> #include<vector> #include<queue> using namespace std; template<typename T> //luosansui class TreeNode { public: T value; TreeNode* left; TreeNode* right; Tr原创 2020-12-09 15:46:10 · 2056 阅读 · 9 评论