Retourner au contenu associé (entrée de forum : [Algorithmie] question sur les arbres binaires)
Posté par dkremer le 05 avril 2009 à 21:06. En réponse au message [Algorithmie] question sur les arbres binaires. Évalué à 2.
void index_huffman_tree(unsigned int depth, unsigned int bit, huffman_tree * root, huffman_tree * huffman_index) { unsigned int char_pos ; unsigned int bit_pos ; unsigned char bin_mask ; unsigned char index ; /* modification du noeud de l'arbre */ root->bit_size = depth ; /* taille du mot en bits */ char_pos = (depth/CHAR_BIT) ; bit_pos = (depth%CHAR_BIT) ; if (bit) { bin_mask = (unsigned char)(pow(2,bit_pos)) ; } else { bin_mask = 0 ; } root->bin_word[char_pos] = (root->bin_word[char_pos] | bin_mask) ; /* appel recursif sur les noeuds suivants */ if( root->left!=NULL && root->right!=NULL ) { index_huffman_tree(depth+1,0,root->left,huffman_index) ; index_huffman_tree(depth+1,1,root->right,huffman_index) ; } else { i_index = (unsigned char)(root->character) ; huffman_index[index] = *root ; } }
AltStyle によって変換されたページ (->オリジナル) / アドレス: モード: デフォルト 音声ブラウザ ルビ付き 配色反転 文字拡大 モバイル
[^] # Re: wikipedia ?
Posté par dkremer . En réponse au message [Algorithmie] question sur les arbres binaires. Évalué à 2.
void index_huffman_tree(unsigned int depth, unsigned int bit, huffman_tree * root, huffman_tree * huffman_index) { unsigned int char_pos ; unsigned int bit_pos ; unsigned char bin_mask ; unsigned char index ; /* modification du noeud de l'arbre */ root->bit_size = depth ; /* taille du mot en bits */ char_pos = (depth/CHAR_BIT) ; bit_pos = (depth%CHAR_BIT) ; if (bit) { bin_mask = (unsigned char)(pow(2,bit_pos)) ; } else { bin_mask = 0 ; } root->bin_word[char_pos] = (root->bin_word[char_pos] | bin_mask) ; /* appel recursif sur les noeuds suivants */ if( root->left!=NULL && root->right!=NULL ) { index_huffman_tree(depth+1,0,root->left,huffman_index) ; index_huffman_tree(depth+1,1,root->right,huffman_index) ; } else { i_index = (unsigned char)(root->character) ; huffman_index[index] = *root ; } }