Timeline for Huffman Coding in Swift
Current License: CC BY-SA 4.0
8 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Dec 5, 2018 at 15:51 | comment | added | Turnipdabeets |
I was also thinking maybe the encrypted code should contain the tree/key rather than separate them… maybe as the first element in the array for code or maybe return a struct with these two values. What are your thoughts about keeping the values together like that? The instance var code is readable but its an array of zeros and ones. Is there a benefit of having a string of zeros and ones vs an array? I’ll have to google around for compressing the string or array of strings.
|
|
| Dec 5, 2018 at 15:50 | comment | added | Turnipdabeets | Thanks for that example. I’ll rework on the weights. Can you elaborate on the API improvements? An initializer that takes a previously created Huffman tree is a great idea. But is it better to retrieve and initialize with the tree or the key that I generate from the tree? My thought was that the key is O(n) look up so better than the tree. | |
| Dec 5, 2018 at 15:32 | vote | accept | Turnipdabeets | ||
| Dec 4, 2018 at 22:53 | history | edited | Martin R | CC BY-SA 4.0 |
added 8 characters in body
|
| Dec 4, 2018 at 22:48 | history | edited | Martin R | CC BY-SA 4.0 |
added 459 characters in body
|
| Dec 4, 2018 at 22:22 | comment | added | Martin R |
@Turnipdabeets: Here is an example: You start with weights 1, 1, 1, 1, 1, 1. Then the last two are joined: 1, 1, 1, 1, 2. Then 1, 1, 2, 2. Now the first two should be joined, but your algorithm looks only at the last three. – Also for nodes with equal weight the one with lower height should be chosen.
|
|
| Dec 4, 2018 at 21:47 | comment | added | Turnipdabeets | Thanks! I need to spend some time thinking through all your suggestions. Wouldn't the last two or three nodes always be of minimal total weight if I've sorted in that order? | |
| Dec 4, 2018 at 21:37 | history | answered | Martin R | CC BY-SA 4.0 |