
数据结构作业
数据结构课堂、课后、实验作业
繁星伴晚安
热爱诗和代码
展开
-
【数据结构】哈夫曼树实现文件的压缩与解压缩
哈夫曼树实现文件的压缩与解压缩原创 2021-06-06 21:44:24 · 1698 阅读 · 0 评论 -
【数据结构】哈夫曼树的前期准备(二)
注意: 所有的准备工作只是为了将这个题目分解成很多小问题解决,而最终我写的哈夫曼解压缩代码会与准备工作有很大区别。根据得到的哈夫曼树,生成编码生成编码需要用到递归函数递归函数首先确定函数的形参和返回值,明确函数的作用。其次,确定递归之间的关联。最后确定终止条件。写压缩文件现在,我需要再次读取data.txt内容,每次读取一个字节,前面的工作已经可以得到文件中每一个字符对应的哈夫曼编码了。如何根据一个字符串(由8位二进制组成)确定其对应的ASCLL编码?在内存中,任何一个ASCL原创 2021-06-03 23:39:17 · 198 阅读 · 0 评论 -
【数据结构】哈夫曼树前期准备(一)
哈夫曼树以及文件压缩的实现前期准备随机生成0~127的数#include<math.h>#include<time.h>#include<stdlib.h>int main() { int n; srand(time(NULL)); for (int i = 0; i < 10; i++) { n = rand() % 128; cout << n << " "; } }输出随机生成的数对应的ASCLL原创 2021-05-30 16:23:17 · 209 阅读 · 2 评论 -
【QT】信号和槽
信号和槽运行,尝试一下。原创 2021-05-16 15:26:30 · 133 阅读 · 0 评论 -
【数据结构】实验作业07- 将二叉树后序线索化并进行后序遍历
threadedBinaryTree.h:#pragma once#include<iostream>using namespace std;#include<stack>template<class T>struct threadedBinaryTreeNode { T element; int lTag, rTag;//lTag为0指向左孩子节点,为1指向前驱节点 threadedBinaryTreeNode<T>* leftLink,.原创 2021-05-15 14:39:06 · 376 阅读 · 0 评论 -
【数据结构】实验作业06-设计算法实现求解森林的高度
forest.h#pragma once#ifndef forest_#define forest_#include<iostream>#include<queue>using namespace std;template<class T>struct forestNode { T data; forestNode<T>* firstson; forestNode<T>* nextbrother; forestNode(T原创 2021-05-14 19:39:42 · 1103 阅读 · 0 评论 -
【数据结构】二叉树的线性存储
arrayBinaryTree.h#include<iostream>using namespace std;#include<string>class arrayBinaryTree{public: arrayBinaryTree(); ~arrayBinaryTree(); bool emppty()const; int size()const; void creatTree();//创建树 void preOrder(int i);//先序遍历 vo原创 2021-05-11 23:10:55 · 476 阅读 · 0 评论 -
【数据结构】链式二叉树的创建
binaryTreeNode.h#pragma once#include<iostream>template<class T>struct binaryTreeNode{ T element; binaryTreeNode<T>* leftChild, * rightChild; binaryTreeNode() {} binaryTreeNode(const T& element, binaryTreeNode<T>* leftCh原创 2021-05-10 21:45:03 · 570 阅读 · 0 评论 -
【数据结构】递归程序的非递归实现
用递归代码实现斐波那契数列求解,利用转换规则(不简化) 将递归代码转换为非递归代码。(C++)求1+2+3+…+n的和:递归做法int sum(int n) { if (n == 0) return 0; else { return n + sum(n - 1); }}非递归的实现#include<iostream>using namespace std;#include<stack>int sum(int n) {//非递归 i原创 2021-05-02 18:22:49 · 880 阅读 · 0 评论 -
【数据结构】【实验作业05】求两个集合的并集、交集、差集,集合用链表
返回临时对象会执行析构函数我的解决方法时在函数内部用类指针,返回类指针就不会有问题了。不知道大家还有没有其他解决方法。复制构造函数和重载=的区别这里不讲述为什么要使用复制构造函数和重载=(自行百度)C++中调用复制构造函数的三种情况:第一种:Myclass A=B;第二种:fun(Myclass a); 对象作为参数传递第三种:a = fun();1.通过一个对象构造另一个对象2.调用参数为对象的函数3.调用返回值为对象的函数...原创 2021-04-18 11:23:56 · 2296 阅读 · 0 评论 -
【数据结构】建立双循环链表实验作业-04
chainNode.h#pragma once#include<iostream>template<class T>struct chainNode{ T element; chainNode<T>* next; chainNode<T>* front; chainNode(){} chainNode(const T& element, chainNode<T>* next = NULL,chainNode<T&.原创 2021-04-10 17:12:47 · 145 阅读 · 0 评论 -
【C++】用两个栈实现计算器
用两个栈实现计算器 - 程序设计原创 2021-03-26 20:07:04 · 1674 阅读 · 1 评论 -
【C++】生成随机数写入文件中,并从文件中读取数据进行排序
#include<iostream>using namespace std;#include<stdlib.h>#include<math.h>#include<time.h>#include<fstream>#include<iomanip>int num[100000000];int n = 10000;void CreatNum(int n) { ofstream ofs; ofs.open("D:\\dat原创 2021-03-14 18:42:46 · 2230 阅读 · 0 评论