{"id":45418,"date":"2023-12-11T15:05:47","date_gmt":"2023-12-11T07:05:47","guid":{"rendered":"https:\/\/wx.kaifamiao.info\/?p=45418"},"modified":"2023-12-11T15:05:47","modified_gmt":"2023-12-11T07:05:47","slug":"%e7%bb%99%e5%ae%9a%e4%b8%80%e4%b8%aa%e6%95%b0%e5%ad%97%e6%95%b0%e7%bb%84%ef%bc%8c%e8%bf%94%e5%9b%9e%e5%93%88%e5%a4%ab%e6%9b%bc%e6%a0%91%e7%9a%84%e5%a4%b4%e6%8c%87%e9%92%88%ef%bc%9f-2","status":"publish","type":"post","link":"http:\/\/wx.kaifamiao.info\/index.php\/2023\/12\/11\/%e7%bb%99%e5%ae%9a%e4%b8%80%e4%b8%aa%e6%95%b0%e5%ad%97%e6%95%b0%e7%bb%84%ef%bc%8c%e8%bf%94%e5%9b%9e%e5%93%88%e5%a4%ab%e6%9b%bc%e6%a0%91%e7%9a%84%e5%a4%b4%e6%8c%87%e9%92%88%ef%bc%9f-2\/","title":{"rendered":"\u7ed9\u5b9a\u4e00\u4e2a\u6570\u5b57\u6570\u7ec4\uff0c\u8fd4\u56de\u54c8\u592b\u66fc\u6811\u7684\u5934\u6307\u9488\uff1f"},"content":{"rendered":"<p>&#8220;`&#8221;<\/p>\n<p>&lt;pre&gt;&lt;code&gt;struct BTreeNode* CreateHuffman(ElemType a[], int n)<br \/>\n{<br \/>\nint i, j;<br \/>\nstruct BTreeNode **b, *q;<br \/>\nb = malloc(n*sizeof(struct BTreeNode));<br \/>\nfor (i = 0; i &lt; n; i++)<br \/>\n{<br \/>\nb[i] = malloc(sizeof(struct BTreeNode));<br \/>\nb[i]-&gt;data = a[i];<br \/>\nb[i]-&gt;left = b[i]-&gt;right = NULL;<br \/>\n}<br \/>\nfor (i = 1; i &lt; n; i++)<br \/>\n{<br \/>\nint k1 = -1, k2;<br \/>\nfor (j = 0; j &lt; n; j++)<br \/>\n{<br \/>\nif (b[j] != NULL &amp;&amp; k1 == -1)<br \/>\n{<br \/>\nk1 = j;<br \/>\ncontinue;<br \/>\n}<br \/>\nif (b[j] != NULL)<br \/>\n{<br \/>\nk2 = j;<br \/>\nbreak;<br \/>\n}<br \/>\n}<br \/>\nfor (j = k2; j &lt; n; j++)<br \/>\n{<br \/>\nif (b[j] != NULL)<br \/>\n{<br \/>\nif (b[j]-&gt;data &lt; b[k1]-&gt;data)<br \/>\n{<br \/>\nk2 = k1;<br \/>\nk1 = j;<br \/>\n}<br \/>\nelse if (b[j]-&gt;data &lt; b[k2]-&gt;data)<br \/>\nk2 = j;<br \/>\n}<br \/>\n}<br \/>\nq = malloc(sizeof(struct BTreeNode));<br \/>\nq-&gt;data = b[k1]-&gt;data + b[k2]-&gt;data;<br \/>\nq-&gt;left = b[k1];<br \/>\nq-&gt;right = b[k2];<br \/>\nb[k1] = q;<br \/>\nb[k2] = NULL;<br \/>\n}<br \/>\nfree(b);<br \/>\nreturn q;<br \/>\n}<br \/>\n&lt;\/code&gt;&lt;\/pre&gt;<\/p>\n<p>\u00a0<\/p>\n<p>&lt;pre&gt;&lt;code&gt;            &quot;&#8220;`<br \/>\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>&#8220;`&#8221; &lt;pre&gt;&lt;code&gt;struct BTreeNode [&hellip;]<\/p>\n","protected":false},"author":7,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[101],"tags":[],"class_list":["post-45418","post","type-post","status-publish","format-standard","hentry","category-c"],"_links":{"self":[{"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/posts\/45418","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/comments?post=45418"}],"version-history":[{"count":1,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/posts\/45418\/revisions"}],"predecessor-version":[{"id":45419,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/posts\/45418\/revisions\/45419"}],"wp:attachment":[{"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/media?parent=45418"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/categories?post=45418"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/tags?post=45418"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}