bài thuyết trình nhóm 4 -Huffman code


Diễn đàn chia sẻ kiến thức, kinh nghiệm về IT và cuộc sống!
 
Trang ChínhGalleryTìm kiếmLatest imagesĐăng kýĐăng Nhập
Top posters
Sakura (1124)
bài thuyết trình nhóm 4 -Huffman code Vote_lcapbài thuyết trình nhóm 4 -Huffman code Voting_barbài thuyết trình nhóm 4 -Huffman code Vote_rcap 
hotboy (705)
bài thuyết trình nhóm 4 -Huffman code Vote_lcapbài thuyết trình nhóm 4 -Huffman code Voting_barbài thuyết trình nhóm 4 -Huffman code Vote_rcap 
Già Làng (373)
bài thuyết trình nhóm 4 -Huffman code Vote_lcapbài thuyết trình nhóm 4 -Huffman code Voting_barbài thuyết trình nhóm 4 -Huffman code Vote_rcap 
con_ca_nho90 (289)
bài thuyết trình nhóm 4 -Huffman code Vote_lcapbài thuyết trình nhóm 4 -Huffman code Voting_barbài thuyết trình nhóm 4 -Huffman code Vote_rcap 
that_true (154)
bài thuyết trình nhóm 4 -Huffman code Vote_lcapbài thuyết trình nhóm 4 -Huffman code Voting_barbài thuyết trình nhóm 4 -Huffman code Vote_rcap 
theanhkkt (143)
bài thuyết trình nhóm 4 -Huffman code Vote_lcapbài thuyết trình nhóm 4 -Huffman code Voting_barbài thuyết trình nhóm 4 -Huffman code Vote_rcap 
phamay (137)
bài thuyết trình nhóm 4 -Huffman code Vote_lcapbài thuyết trình nhóm 4 -Huffman code Voting_barbài thuyết trình nhóm 4 -Huffman code Vote_rcap 
lovelonelyman (134)
bài thuyết trình nhóm 4 -Huffman code Vote_lcapbài thuyết trình nhóm 4 -Huffman code Voting_barbài thuyết trình nhóm 4 -Huffman code Vote_rcap 
o0ovioletstaro0o (128)
bài thuyết trình nhóm 4 -Huffman code Vote_lcapbài thuyết trình nhóm 4 -Huffman code Voting_barbài thuyết trình nhóm 4 -Huffman code Vote_rcap 
stevenhung (122)
bài thuyết trình nhóm 4 -Huffman code Vote_lcapbài thuyết trình nhóm 4 -Huffman code Voting_barbài thuyết trình nhóm 4 -Huffman code Vote_rcap 
Âm - Dương lịch
Clock
Logo
11TH02 Pro!
Liên kết
Tin tức 60s
Tin công nghệ
Thời sự 24h
Game Moblie

Share
 

 bài thuyết trình nhóm 4 -Huffman code

Xem chủ đề cũ hơn Xem chủ đề mới hơn Go down 
Tác giảThông điệp
hotboy

bài thuyết trình nhóm 4 -Huffman code Stars7
hotboy

Thú CƯng : bài thuyết trình nhóm 4 -Huffman code Hippopotamus-icon
Nam Aries

Số bài viết : 705
Điểm : 1043
Được cảm ơn : 9
Ngày sinh : 21/03/1990
Tham gia ngày : 13/05/2010
Tuổi : 34
Đến từ : BDU

bài thuyết trình nhóm 4 -Huffman code Empty
Bài gửiTiêu đề: bài thuyết trình nhóm 4 -Huffman code   bài thuyết trình nhóm 4 -Huffman code I_icon_minitime16/6/2010, 09:54

[You must be registered and logged in to see this link.]

anh em xem xong cho ý kiến
Về Đầu Trang Go down
hotboy

bài thuyết trình nhóm 4 -Huffman code Stars7
hotboy

Thú CƯng : bài thuyết trình nhóm 4 -Huffman code Hippopotamus-icon
Nam Aries

Số bài viết : 705
Điểm : 1043
Được cảm ơn : 9
Ngày sinh : 21/03/1990
Tham gia ngày : 13/05/2010
Tuổi : 34
Đến từ : BDU

bài thuyết trình nhóm 4 -Huffman code Empty
Bài gửiTiêu đề: Re: bài thuyết trình nhóm 4 -Huffman code   bài thuyết trình nhóm 4 -Huffman code I_icon_minitime16/6/2010, 09:59

do sơ suất nên chưa đính kèm code.nên phải quăng ra đây,anh em chịu khó chút
Code:
//------------------------------------------------------
// 
//  this coding is about huffman algorithm.
//  in this coding, i assume that all of you know about
//  huffman algorithm
//
//  Author: Andy Gunawan
//-------------------------------------------------------

#include<iostream.h>

struct tree
{  int value;
    char ch;
    tree *left;
    tree *right;
};

struct input
{  int frequency;
    char character;
    tree *address;
};

void postorder(tree *root,int node,char *temp_bit)
{  node++;
    if(root!=0)
    {  temp_bit[node-1]='0';
        postorder(root->left,node,temp_bit);
        temp_bit[node-1]='\0';
     
        temp_bit[node-1]='1';
        postorder(root->right,node,temp_bit);
        temp_bit[node-1]='\0';

        if(root->ch!='\0')
            cout<<root->ch<<" : "<<temp_bit<<endl;
    }
    node--;
}
 
tree *inputTree(input num_input1,input num_input2)
{  tree *leftnode = new tree;
    tree *rightnode = new tree;
    tree *root=new tree;
 
    if(num_input1.address=='\0')
    {  leftnode->value = num_input1.frequency;
        leftnode->ch = num_input1.character;
        leftnode->left = '\0';
        leftnode->right = '\0';
    }
    else
    {  leftnode = num_input1.address;  }
 
    if(num_input2.address=='\0')
    {  rightnode->ch=num_input2.character;
        rightnode->value=num_input2.frequency;
        rightnode->left='\0';
        rightnode->right='\0';
    }
    else
    {  rightnode = num_input2.address; }

    root->value=num_input1.frequency+num_input2.frequency;
    root->ch='\0';
    root->left=leftnode;
    root->right=rightnode;

    return root;
}

void bubble(input *number_input,int counter)
{  for(int i=0;i<counter-1;i++)
        for(int j=i+1;j<counter;j++)
            if(number_input[i].frequency > number_input[j].frequency)
            {  input *temp = new input;

                temp->address = number_input[i].address;
                temp->character = number_input[i].character;
                temp->frequency = number_input[i].frequency;
                number_input[i].address = number_input[j].address;
                number_input[i].character = number_input[j].character;
                number_input[i].frequency = number_input[j].frequency;
                number_input[j].address = temp->address;
                number_input[j].character = temp->character;
                number_input[j].frequency = temp->frequency;
             
                delete temp;
            }
}

int main(void)

        int number,node=0;

    cout<<"How many character will you input? ";
    cin>>number;
 
    char *temp_bit = new char[number];
    input *num_input = new input[number];

    for(int p=0;p<number;p++)
    {  num_input[p].address='\0';
        num_input[p].frequency=0;
        num_input[p].character='\0';
    }
 
    for(int i=0;i<number;i++)
    {  cout<<"\nEnter character: ";
        cin>>num_input[i].character;
        cout<<"Enter frequency: ";
        cin>>num_input[i].frequency;
    }

    for(int j=0;j<number-1;j++)
    {  bubble(num_input,number);

        num_input[j+1].address=inputTree(num_input[j],num_input[j+1]);
        num_input[j+1].frequency += num_input[j].frequency;
        num_input[j+1].character = '\0';
    }
 
    cout<<endl;
    postorder(num_input[number-1].address,node,temp_bit);
    cout<<endl;

    delete temp_bit;
    delete num_input;
    return 0;
}
Về Đầu Trang Go down
Sakura

bài thuyết trình nhóm 4 -Huffman code Stars7
Sakura

Thú CƯng : bài thuyết trình nhóm 4 -Huffman code I-hate-Cats-icon
Nam Scorpio

Số bài viết : 1124
Điểm : 1688
Được cảm ơn : 35
Ngày sinh : 03/11/1990
Tham gia ngày : 16/03/2010
Tuổi : 33
Đến từ : Bình Dương
Ngề nghiệp : IT Student

bài thuyết trình nhóm 4 -Huffman code Empty
Bài gửiTiêu đề: Re: bài thuyết trình nhóm 4 -Huffman code   bài thuyết trình nhóm 4 -Huffman code I_icon_minitime16/6/2010, 19:19

thú vị quá! thật là xuất sắc! mà mình nghĩ cần phải chỉnh sửa nhiều đó! 1 chương trình phải kiểm soát được tất cả các ngoại lệ xảy ra thì ct đó mới có thể đứng vững được!
Góp ý tí! có gì đừng oánh tui nha!
Về Đầu Trang Go down
Sponsored content




bài thuyết trình nhóm 4 -Huffman code Empty
Bài gửiTiêu đề: Re: bài thuyết trình nhóm 4 -Huffman code   bài thuyết trình nhóm 4 -Huffman code I_icon_minitime

Về Đầu Trang Go down
 

bài thuyết trình nhóm 4 -Huffman code

Xem chủ đề cũ hơn Xem chủ đề mới hơn Về Đầu Trang 
Trang 1 trong tổng số 1 trang

 Similar topics

-
» Ai có thể gom tất cả các bài thuyết trình của các nhóm lại ko?
» Bài Thuyết Trình STL Nhóm NO1! Mời Các Bạn Góp Ý!
» Bài thuyết trình ngày mai của nhóm Tài nè anh em
» Tổng hợp các bài thuyết trình của các nhóm!
» Bài thuyết trình Thương Mại Điện Tử nhóm NO.1

Permissions in this forum:Bạn không có quyền trả lời bài viết
IT World! :: HỌC TẬP :: Học Kỳ IV :: Cấu Trúc Dữ Liệu Và Giải Thuật 2-