【list】可用于哈夫曼树的一种建树选数的链表方法替代堆

#include
#include
#include
using namespace std;
int a[]={1,2,3,4,5,6,7,8,9};
struct node
{
node(int xx):x(xx),next(NULL){}
int x; 
 node *next;
};
void fun()
{
 
}
int main()
{
node *head=new node(0);
node *p=head;
for(int i=0;i<9;i++)
{
node *add=new node(a[i]);
p->next=add;
p=add;
}

 node *q=head;
while(q)
{
cout<x<<" ";
q=q->next;
}
cout<next;
q=p->next;
while(p->next!=NULL)
{

node *add=new node(p->x+q->x);
node  *qq=q; 
 while(add->x > qq->x && qq->next!=NULL)
     {
      qq=qq->next;
     }
  add->next=qq->next;
  qq->next=add;
  cout<x<next;
q=p->next;
}


 q=head;
while(q)
{
cout<x<<" ";
q=q->next;
}
cout<            
            
                        
本文标题:【list】可用于哈夫曼树的一种建树选数的链表方法替代堆
当前链接:http://hxwzsj.com/article/pgghce.html

其他资讯

Copyright © 2025 青羊区翔捷宏鑫字牌设计制作工作室(个体工商户) All Rights Reserved 蜀ICP备2025123194号-14
友情链接: 网站建设公司 四川成都网站制作 成都网站建设公司 成都网站建设 响应式网站设计方案 温江网站设计 网站建设公司 重庆手机网站建设 品牌网站建设 成都网站建设 响应式网站设计 企业网站建设公司 重庆外贸网站建设 成都企业网站建设公司 成都网站设计 网站设计 成都网站建设推广 企业网站设计 定制网站制作 网站建设方案 企业网站设计 成都商城网站制作