💾 Archived View for jaeyoung.se › posts › 2023-02-27_huffman_coding captured on 2023-04-26 at 13:10:37. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2023-03-20)

-=-=-=-=-=-=-

date = 2023-02-27
tags = ["compsci", "deno"]
title = "Huffman Coding Deno program"

Huffman Coding Deno program

deno run https://jaeyoung.se/jaese/huffman.js

huffman.js is another Deno program I made for fun which performs the Huffman coding algorithm on given text and prints the resulting Huffman table.

Here is an example run. Source text can be given from stdin with the '--stdin' flag.

$ deno run https://jaeyoung.se/jaese/huffman.js
huffman_cli.ts generates and prints a binary tree representation of a Huffman code given a source text.

Pass --help to see the command line options.

Please enter source text: Hello, world!
Huffman code:
├─ 0: (0.400)
│  ├─ 0: O (0.200)
│  └─ 1: (0.200)
│     ├─ 0: R (0.100)
│     └─ 1: (0.100)
│        └─ 1: W (0.100)
└─ 1: (0.600)
   ├─ 0: L (0.300)
   └─ 1: (0.300)
      ├─ 0: E (0.100)
      └─ 1: (0.200)
         ├─ 0: D (0.100)
         └─ 1: H (0.100)

Comments

Leave a comment