题目内容

阅读下列函数说明和C代码,将应填入 (n) 处的字句写在对应栏内。[说明]HufTman树又称最优二叉树,是一类带权路径长度最短的树,在编码中应用比较广泛。构造最优二叉树的Huffman算法如下:①根据给定的n各权值{W1,w2,…,wn)构成n棵二叉树的集合F={T1,T2,…,Tn},其中每棵树Ti中只有一个带权为wi的根节点,其左右子树均空。②在F中选取两棵根节点的权值较小的树作为左右子树,构造一棵新的二叉树,置新构造二叉树的根节点的权值为其左右予树根节点的权值之和。③从F中删除这两棵树,同时将新得到的二叉树加入到F中。重复②③,直到F中只剩一棵树为止。函数中使用的预定义符号如下:#define INT MAX 10000#define ENCODING LENGTH 1000typedef enum(none,left_child,right_child) Which;/*标记是左孩子还足右孩子*/typedef char Elemtype;typedef struct TNode{//Huffman树节点Elemtype letter;intweight; //权值int parent; //父节点Which sigh;char *code; //节点对应编码}HTNode,*HuffmanTree;int n;char coding[50];//储存代码[函数]void Select(HuffmanTree HT,int end,int *sl,int *s2)/*在0~END之间,找出最小和次小的两个节点序号,返吲S1、S2*/{int i;int min 1=INT_MAX;int min 2=INT_MAX;for(i=0;i<=end;i++){/*找最小的节点序号*/if(( (1) )&&(HT[i].weight<minl)){*s1=i;min 1=HT[i].weight;}}for(i=0;i<=end;i++){/*找次小节点的序号*/if((HT[i].parent==0)&&( (2) )&&(min 2>HT[i].weight)){*s2=i;min 2=HT[i].weight;}}}void HuffmanTreeCreat(HuffmanTree&HT)/*建立HUFFMAN树*/{int i;int m=2*n-1;int s1,s2;for(i=n;i<m;i++){Select( (3) );HT[s1].parent=i;HT[s2].parent=i;HT[s1].sigh=left child;HT[s2].sigh=right child;HT[i].weight= (4) ;}}void HuffmanTreeEncoding(char sen[],HuffmanTree HT){ /*将句子进行编码*/int i=0;int j;while(sen[i] !=’\0’){for(j=0;j<n;j++){if(HT[j].letter==sen[i])(/*字母吻合则用代码取代*/strcat(coding, (5) );break;}}i++;if (Sen [1]==32) i++;}printf("\n%s",coding);} (2)处填()。

查看答案
更多问题

Questions 18 to 20 are based on the following passage. At the end of the passage, you will be given 15 seconds to answer the questions. Now listen to the passage How far does the Arab look back for his own origins

A. Twenty thousand years,
B. Two to six thousand years,
C. A thousand years.
D. Hundreds of years.

You are going to celebrate your tenth anniversary with your husband Jim. Write to invite Betty and her husband Tom to the party. Marks will be awarded for content, organization, grammar and appropriateness.

Questions 4 to 7 are based on the following conversation. At the end of the conversation, you will be given 20 seconds to answer the questions. Now listen to the conversation. What is the final offer of a raise the man makes Miss Barnes

A. Twice her present salary:
B. Ten dollars more per week.
C. The same as Snodgrass. Ellington and Pitts.
D. Ten dollars more per week than Snodgrass, Ellington and Pitts.

战略数据规划方法认为,实体分析是自顶向下确定企业实体的过程,而经验证明,实体分析过程需安排______处理的高级管理人员参加。

答案查题题库