Hi,
Background: this is the last part of my implementation of the huffman compression. The good news is,
it seems to work the print(decoded_string)
give back the string it decoded before. But it does not return it. it returns nothing
the value of decoded_string
is ""
initially.
other parameter are:
encoded_string
: is a string with 1’s and 0’s.
key_encoding_array
: an array of tuples with the structure Vector{Tuple{String, String,Int64}}
function rebuilding_message(encoded_string,key_encoding_array::Vector{Tuple{String, String,Int64}},decoded_string)
if isempty(encoded_string)
print(decoded_string)
return decoded_string
else
for i in key_encoding_array
if length(encoded_string) >= i[3] && i[2] == encoded_string[1:i[3]]
rebuilding_message(SubString(encoded_string,(i[3]+1)),key_encoding_array,string(decoded_string,i[1]))
end
end
end
end
thanks in advance!