I am writing a Huffman Coding/Decoding algorithm and I am running into the problem that the storing the Huffman tree is taking up way to much room. Currently, I am converting the tree into a hashMap as such -> hashMap<Character(s),Huffman Code> and then storing that hash map. The issue is that, while the string is compressed great, adding the Huffman Tree data stored in the hash map is adding so much overhead that it's actually ending up bigger than the original. Currently I am just naively writing [data, value] pairs to the file, but I imagine there must be some sort of trickier way to do that. Any ideas?
How to write a hashmap to a file in a memory efficient format?
220 Views Asked by Brett At
1
There are 1 best solutions below
Related Questions in MEMORY
- 9 Digit Addresses in Hexadecimal System in MacOS
- Memory location changing from 0 to 1 consistently on Mac
- Would event listeners prevent garbage collecting objects referenced in outer function scopes?
- tensorrt inference problem: CPU memory leak
- How to estimate the memory size of a binary voxelized geometry?
- Java Memory UTF-16 Vs UTF-8
- Spring Boot application container memory footprint (Java 21)
- Low memory Windows CE
- How to throw an error when a program acesses a block of memory created by you that has been deallocated by a call of free?
- Golang bufio.Scanner: token too long
- Get the address and size of a loaded shared object on memory from C
- In Redis Databases how do we need to calculate the table size
- ClickHouse Materialized View consuming a lot of Memory and CPU
- How to reduce memory usage for large matrix calculations?
- How to use memray with Gunicorn or flask dev server?
Related Questions in COMPRESSION
- Should I compress images in java backend before sending to frontend?
- saving always adds artefacts to my images that photoshop doesn't
- Kafka compression on Broker side
- I am trying to compress video in Android using ffmpeg
- Compress gzip/Deflate string with golang
- how to convert different length of bits into byte array?
- knowledge distillation in a multistep model
- How to decompress the contents of a var to another var?
- Why response body not compressed when use webtestclient?
- How to monkey-patch np.savez_compressed to add compression level, without editing numpy's source files?
- incorrect header check while implementing GZIP in spring boot REST APIs
- Create algorhitm to create .pak file from unpack code
- Problem with decompressing algorithm in firefox (works in chrome/edge)
- Can I ignore some keyword while compressing css file through webpack? In other words I need a loader which just compress my file without validation
- PNG cropping increases file size
Related Questions in HUFFMAN-CODE
- How can one correctly extract Huffman Tree from a dynamic compressed block?
- Is it possible match initial bytes of Deflate compressed data using knowledge of first portion of uncompressed data?
- How to handle the remaining bits in file decompression
- Index Out of Range error when Huffman Coding
- Does the BRCI algorithm work for *all* Huffman Trees?
- How to transfer a String data which starts with "0" to a byte type , and recover it without losing the "0" at the first place?
- How can I read a binary file bit-by-bit?
- How to find the set of binary symbols that can most efficiently compress using Huffman coding?
- huffman table in jpeg decoding
- Iterate through all possible code length distributions for canonical Huffman
- My program writes a string when its supposed to write bytes
- What is the process of counting the frequencies of each character which is then feeded into huffman encoding?
- Why is there a optimal Huffman table in the header of a progressive JPEG image?
- Compute the compression ratio by using Huffman encoding
- Compute the compression ratio for Huffman algorithm
Related Questions in MEMORY-EFFICIENT
- R: Efficient Way to partly modify diagonal of matrix
- The Reason Behind Employing an Additional Array and Counting Smaller Elements in the Counting Sort Algorithm
- Efficient way to iterate through df rows
- How to correctly reuse data in registers to compute faster the Pearson Correlation between vectors in a matrix
- Search in txt file with more than 3 million lines in C#
- How to generate all length n combinations of k elements (with replacement) that contain each element at least once?
- Given two arrays A and B, how to efficiently combine them so that the output is an array in which each element is a tuple (Aij,Bij)?)
- Fast and efficient substring extraction and comparison in R
- How to be more code efficient on fortran? I solved an exercise and I'm not satisfied with my own answer
- Efficiently enumerating multinomials with constant sum - R
- What's most efficient way of reading larger files in python?
- Running out of memory modifying a long string
- How to shuffle a function consistently from a seed number
- Improving CLOS memory-efficiency in Common Lisp?
- Compact way to save a list of subsets
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular # Hahtags
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
You do not need the tree in order to encode. All you need is the bit lengths for each symbol and a way to order the symbols. See Canonical Huffman Code.
In fact, all you need is the symbols that are coded ordered by bit length, and within bit length sorted by symbol, and then the number of codes of each length. With just those two things you can encode.