We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
The root of the node tells how many characters there are , so you could initialize the StringBuilder with a capacity of root.frequency.
It's questionable whether System.out.print() is faster, because it may print character by character, which is potentially slower, or maybe System.out uses an internal buffer and prints it out once the size goes past a threshold.
Tree: Huffman Decoding
You are viewing a single comment's thread. Return to all comments →
The root of the node tells how many characters there are , so you could initialize the StringBuilder with a capacity of root.frequency.
It's questionable whether System.out.print() is faster, because it may print character by character, which is potentially slower, or maybe System.out uses an internal buffer and prints it out once the size goes past a threshold.