Skip to main content

huffman_encoded_len

Function huffman_encoded_len 

Source
pub fn huffman_encoded_len(text: &str) -> usize
Expand description

Matn Huffman bilan kodlanganda necha bit egallaydi.

Solishtirish uchun: oddiy ASCII da har belgi 8 bit.

§Misol

use rust_algorithms::greedy::huffman_encoded_len;

let matn = "abracadabra";
let huffman_bit = huffman_encoded_len(matn);
let ascii_bit = matn.len() * 8;
assert_eq!(huffman_bit, 23);
assert!(huffman_bit < ascii_bit); // 23 < 88 — 74% siqildi