Bob has found in his granny's cellar an old box with strange messages inside. Most of them are almost unreadable since the paper is very old. His granny is very happy since she believed this box was lost. she remembers when she was a student in mathematics, she was using a secret cipher to correspond with her boyfriend. The box contains some encrypted messages. One of the messages is still readable: IEHMTALVOHETMAIVLO

Bob is fascinated and asks his granny to decrypt it, but the old lady only accepts to explain him the main principle of the cipher:  if you want to read it you must deserve it’’, she said. But it is simple: divide the code into two equal parts and verify that both parts contain the same letters. The first part corresponds to a pre-order while the second corresponds to an in-order of a binary tree. Find the related binary tree and read it in reverse post-order.’’

After reading carefully the message she adds: You are lucky, here each letter occurs only once in each part. I remember we invented a specific code when there were several occurrences of the same letter with possible ambiguity.Bob is quite confused and asks more details but she refuses to help him more. She still likes to play. Bob would like to understand well in order to use this cipher for sending messages to Alice. Can you help him understand this message?

2. Re: The Old Lady's Cipher

Bob has found in his granny's cellar an old box with strange messages inside. Most of them are almost unreadable since the paper is very old. His granny is very happy since she believed this box was lost. she remembers when she was a student in mathematics, she was using a secret cipher to correspond with her boyfriend. The box contains some encrypted messages. One of the messages is still readable: IEHMTALVOHETMAIVLO

Bob is fascinated and asks his granny to decrypt it, but the old lady only accepts to explain him the main principle of the cipher:  if you want to read it you must deserve it’’, she said. But it is simple: divide the code into two equal parts and verify that both parts contain the same letters. The first part corresponds to a pre-order while the second corresponds to an in-order of a binary tree. Find the related binary tree and read it in reverse post-order.’’

After reading carefully the message she adds: You are lucky, here each letter occurs only once in each part. I remember we invented a specific code when there were several occurrences of the same letter with possible ambiguity.Bob is quite confused and asks more details but she refuses to help him more. She still likes to play. Bob would like to understand well in order to use this cipher for sending messages to Alice. Can you help him understand this message?
Sounds like granny has picked up a couple of new tricks!

-Dan