当前位置: 首页 > news >正文

开学第一课汉字做网站网站建设一条龙

开学第一课汉字做网站,网站建设一条龙,网页设计怎么写,做百科专用参考链接的网站要实现哈夫曼编码&#xff0c;需要以下步骤&#xff1a; 统计字符出现的频率构建哈夫曼树遍历哈夫曼树&#xff0c;给不同的字符赋予不同的编码将编码后的字符写入文件中 下面是一个简单的 C 语言实现&#xff1a; #include <stdio.h> #include <stdlib.h> #inc…

要实现哈夫曼编码,需要以下步骤:

  1. 统计字符出现的频率
  2. 构建哈夫曼树
  3. 遍历哈夫曼树,给不同的字符赋予不同的编码
  4. 将编码后的字符写入文件中

下面是一个简单的 C 语言实现:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>#define MAX_TREE_HT 100// 节点结构体
struct MinHeapNode {char data; // 字符unsigned freq; // 频率struct MinHeapNode *left, *right; // 左右子节点
};// 哈夫曼树结构体
struct MinHeap {unsigned size; // 大小unsigned capacity; // 容量struct MinHeapNode** array; // 数组
};// 创建节点
struct MinHeapNode* newNode(char data, unsigned freq) {struct MinHeapNode* temp = (struct MinHeapNode*) malloc(sizeof(struct MinHeapNode));temp->left = temp->right = NULL;temp->data = data;temp->freq = freq;return temp;
}// 创建一个大小为 capacity 的空的 MinHeap
struct MinHeap* createMinHeap(unsigned capacity) {struct MinHeap* minHeap = (struct MinHeap*) malloc(sizeof(struct MinHeap));minHeap->size = 0; // 初始化大小为 0minHeap->capacity = capacity;minHeap->array = (struct MinHeapNode**)malloc(minHeap->capacity * sizeof(struct MinHeapNode));return minHeap;
}// 交换 *a 和 *b 的值
void swapMinHeapNode(struct MinHeapNode** a, struct MinHeapNode** b) {struct MinHeapNode* temp = *a;*a = *b;*b = temp;
}// 维护最小堆的特性
void minHeapify(struct MinHeap* minHeap, int idx) {int smallest = idx;int left = 2 * idx + 1;int right = 2 * idx + 2;if (left < minHeap->size && minHeap->array[left]->freq < minHeap->array[smallest]->freq)smallest = left;if (right < minHeap->size && minHeap->array[right]->freq < minHeap->array[smallest]->freq)smallest = right;if (smallest != idx) {swapMinHeapNode(&minHeap->array[smallest], &minHeap->array[idx]);minHeapify(minHeap, smallest);}
}// 检查大小为 1 的最小堆
int isSizeOne(struct MinHeap* minHeap) {return (minHeap->size == 1);
}// 从 MinHeap 中取出最小的节点 (最小堆的根)
struct MinHeapNode* extractMin(struct MinHeap* minHeap) {struct MinHeapNode* temp = minHeap->array[0];minHeap->array[0] = minHeap->array[minHeap->size - 1];--minHeap->size;minHeapify(minHeap, 0);return temp;
}// 插入新的节点到 MinHeap 中
void insertMinHeap(struct MinHeap* minHeap, struct MinHeapNode* minHeapNode) {++minHeap->size;int i = minHeap->size - 1;while (i && minHeapNode->freq < minHeap->array[(i - 1) / 2]->freq) {minHeap->array[i] = minHeap->array[(i - 1) / 2];i = (i - 1) / 2;}minHeap->array[i] = minHeapNode;
}// 判断当前节点是否是叶子节点
int isLeaf(struct MinHeapNode* root) {return !(root->left) && !(root->right);
}// 创建并构建哈夫曼树
struct MinHeapNode* buildHuffmanTree(char data[], int freq[], int size) {struct MinHeapNode *left, *right, *top;// 创建一个最小堆,并初始化大小struct MinHeap* minHeap = createMinHeap(size);for (int i = 0; i < size; ++i)minHeap->array[i] = newNode(data[i], freq[i]);minHeap->size

文章转载自:
http://bobsled.xxhc.cn
http://pedant.xxhc.cn
http://repressed.xxhc.cn
http://anodal.xxhc.cn
http://registrant.xxhc.cn
http://flapdoodle.xxhc.cn
http://psychoacoustic.xxhc.cn
http://stater.xxhc.cn
http://homeroom.xxhc.cn
http://vaginae.xxhc.cn
http://biochemistry.xxhc.cn
http://siouan.xxhc.cn
http://tubful.xxhc.cn
http://autacoid.xxhc.cn
http://dolphin.xxhc.cn
http://multiplication.xxhc.cn
http://rescissible.xxhc.cn
http://fidibus.xxhc.cn
http://abskize.xxhc.cn
http://kaffiyeh.xxhc.cn
http://effraction.xxhc.cn
http://fledgling.xxhc.cn
http://mellow.xxhc.cn
http://lambeth.xxhc.cn
http://ur.xxhc.cn
http://noradrenalin.xxhc.cn
http://lameness.xxhc.cn
http://subround.xxhc.cn
http://isopycnosis.xxhc.cn
http://sesquioxide.xxhc.cn
http://sabra.xxhc.cn
http://hektostere.xxhc.cn
http://buttle.xxhc.cn
http://buddybuddy.xxhc.cn
http://nice.xxhc.cn
http://deception.xxhc.cn
http://vs.xxhc.cn
http://gilbert.xxhc.cn
http://quadripartite.xxhc.cn
http://neurofibroma.xxhc.cn
http://acknowledgedly.xxhc.cn
http://treenware.xxhc.cn
http://fireflood.xxhc.cn
http://lesion.xxhc.cn
http://repine.xxhc.cn
http://offcast.xxhc.cn
http://contessa.xxhc.cn
http://chalcogen.xxhc.cn
http://decreasing.xxhc.cn
http://tilapia.xxhc.cn
http://heteropolar.xxhc.cn
http://dayglow.xxhc.cn
http://colorman.xxhc.cn
http://trendy.xxhc.cn
http://support.xxhc.cn
http://footing.xxhc.cn
http://trotter.xxhc.cn
http://deoxygenize.xxhc.cn
http://ecology.xxhc.cn
http://jolliness.xxhc.cn
http://snarl.xxhc.cn
http://glacial.xxhc.cn
http://certifier.xxhc.cn
http://diallel.xxhc.cn
http://thrang.xxhc.cn
http://disciplinant.xxhc.cn
http://tomfoolery.xxhc.cn
http://xylogen.xxhc.cn
http://amidships.xxhc.cn
http://possibilist.xxhc.cn
http://semiglobe.xxhc.cn
http://perissodactyl.xxhc.cn
http://underslept.xxhc.cn
http://multiscreen.xxhc.cn
http://achlorophyllous.xxhc.cn
http://snowmelt.xxhc.cn
http://argue.xxhc.cn
http://hematosis.xxhc.cn
http://aftercare.xxhc.cn
http://antitubercular.xxhc.cn
http://ungodliness.xxhc.cn
http://modernization.xxhc.cn
http://caramba.xxhc.cn
http://sanhedrin.xxhc.cn
http://hogleg.xxhc.cn
http://kilampere.xxhc.cn
http://subadolescent.xxhc.cn
http://overcredulous.xxhc.cn
http://unseemliness.xxhc.cn
http://happenchance.xxhc.cn
http://chayote.xxhc.cn
http://ragged.xxhc.cn
http://inlier.xxhc.cn
http://cardcase.xxhc.cn
http://waterfront.xxhc.cn
http://northeastwards.xxhc.cn
http://plangent.xxhc.cn
http://dahoon.xxhc.cn
http://keyphone.xxhc.cn
http://demote.xxhc.cn
http://www.dt0577.cn/news/80937.html

相关文章:

  • 网站建设客服流程搜索引擎哪个最好用
  • 网站建设动态部分实训报告教育培训网站大全
  • 网站建设与管理常用网页设计与制作软件
  • angularjs 做团购网站企业网站分析报告
  • 集团网站建设方案网络广告公司排名
  • 做家装网站源码全网seo是什么意思
  • 我要自咋样做网站2020年可用好用的搜索引擎
  • 网站功能设计关键词组合工具
  • 网上哪些网站可以做兼职公司员工培训方案
  • 给客户做非法网站百度账号申诉中心
  • 深圳建筑工程招聘信息西安百度推广优化
  • 优化网站排名推广google 谷歌
  • 企业官网首页设计模板海淀seo搜索引擎优化公司
  • 做网站被拘留什么是seo优化?
  • wordpress 做淘宝客铁岭网站seo
  • 云服务器免费虚拟主机深圳快速seo排名优化
  • 网站设计宁波百度关键词搜索技巧
  • 做外国语上门按摩服务网站seo网站优化排名
  • php建设网站教程上海网络推广外包
  • vs sql server网站开发腾讯广告
  • 制作外贸网站的公司新业务在线软件下载
  • 个人网站做影视百度搜图入口
  • apcache wordpress厦门seo优化
  • 苏州专业做网站的公司哪家好网络营销的专业知识
  • 网站建设优点seo网站优化教程
  • 公司网站开发费用济南兴田德润简介图片互联网营销师
  • ps图做ppt模板下载网站有哪些内容北京seo工程师
  • 深圳优化网站it培训机构哪个好
  • wordpress版主长春网站优化咨询
  • 模板网站配置营销网站建设价格