MCPcopy Index your code
hub / github.com/TheAlgorithms/Rust / huffman_encode

Function huffman_encode

src/compression/huffman_encoding.rs:208–222  ·  view source on GitHub ↗

Encodes text using Huffman coding # Arguments `text` - The input string to encode # Returns A tuple containing: - The encoded binary string - A HashMap of character to binary code mappings # Examples ``` # use std::collections::HashMap; # use the_algorithms_rust::compression::huffman_encode; let (encoded, codes) = huffman_encode("hello"); assert!(!encoded.is_empty()); assert!(codes.contains_

(text: &str)

Source from the content-addressed store, hash-verified

source not stored for this graph (policy: none)

Callers 9

test_empty_stringFunction · 0.85
test_single_characterFunction · 0.85
test_simple_stringFunction · 0.85
test_compression_ratioFunction · 0.85
test_unicode_charactersFunction · 0.85

Calls 4

build_frequency_mapFunction · 0.85
build_huffman_treeFunction · 0.85
generate_codesFunction · 0.85
is_emptyMethod · 0.45

Tested by 8

test_empty_stringFunction · 0.68
test_single_characterFunction · 0.68
test_simple_stringFunction · 0.68
test_compression_ratioFunction · 0.68
test_unicode_charactersFunction · 0.68