Question 2 Your uncle James Bond went missing 3 years ago when he went on an office trip. You miss him a lot. He said he worked in a bank, but he always had so many office trips, you always found that strange. Anyways, 3 years after his disappearance, you got a letter with only one message "I open at the close". You immediately knew i was from James, as it is your favourite quote from your favourite book "Harry Potter" and he is the only one who knows it. You got the last harry potter book and opened the page with the quote, and at the bottom in your uncle's handwriting the following note was written: 1. roottdaaaafy 2. taught in summer 3. 10110011010111111100001001001110 You immediately understood what you had to do. James taught you a variable length encoding algorithm in the last summer vacation you had with him. You have find the code of each character in the first line using the encoding algorithm and then use the code of each character to decode the third line. James also gave you some special instructions in case you had to use that algorithm, so that you can decode the code correctly. The instructions are: If any characters have same frequency, then the character that appears first has higher priority (e.g, in above exampler and t have same frequency, sincer appea before t, it will also appear before t in the queue when generating the tree) A new node will always be placed immediately before the next higher frequency node in the queue. E.g.
没有找到相关结果