Retourner au contenu associé (entrée de forum : [Algorithmie] question sur les arbres binaires)
Posté par dkremer le 05 avril 2009 à 18:15. En réponse au message [Algorithmie] question sur les arbres binaires. Évalué à 1.
unsigned int node_count(huffman_tree * root) { if(root->left!=NULL && root->right!=NULL) { return 1 + node_count(root->left) + node_count(root->right); } else { return 0 ; } } unsigned int depth(huffman_tree * root) { if(root->left!=NULL && root->right!=NULL) { return 1+ ( (depth(root->left) > depth(root->right)) ? depth(root->left) : depth(root->right) ) ; } else { return 0; } }
AltStyle によって変換されたページ (->オリジナル) / アドレス: モード: デフォルト 音声ブラウザ ルビ付き 配色反転 文字拡大 モバイル
[^] # Re: wikipedia ?
Posté par dkremer . En réponse au message [Algorithmie] question sur les arbres binaires. Évalué à 1.
unsigned int node_count(huffman_tree * root) { if(root->left!=NULL && root->right!=NULL) { return 1 + node_count(root->left) + node_count(root->right); } else { return 0 ; } } unsigned int depth(huffman_tree * root) { if(root->left!=NULL && root->right!=NULL) { return 1+ ( (depth(root->left) > depth(root->right)) ? depth(root->left) : depth(root->right) ) ; } else { return 0; } }Ce sont des choses qui marchent bien. Je devrai écrire ça de manière récursive, mais je ne vois pas trop comment procéder.