How is the Morse Code representation of a letter determined?
“E” = “.”
“T” = “-“
Why is it not alphabetic? As in let “A” = “.”, “B” = “-“, “C” =”.-“, etc.
I’m trying to develop an algorithm for a traversing Binary Tree filled with these letter.
My main aim is to search for a letter, like “A”, but I don’t know what conditions to use that determines when to branch to the right or left node.
2
A tree is suitable for decoding Morse code, that is converting from dots and dashes to letters. As long as you know where the breaks are between letters, this is entirely feasible.
To go the other way, from letters to dots and dashes, there’s no need to use a tree. Finding a letter in such a tree would be annoying. Just make a simple lookup table:
a => ".-"
b => "-..."
c => "-.-."
The representation of the letters is determined (roughly) by “the frequency of use of letters in the English language . . ., and the letters most commonly used were assigned the shorter sequences of dots and dashes.” You could build a tree with traversing to the left means adding a ‘.’ and traversing to the right means adding a ‘-‘ to the previous code. You may want to also look at Huffman coding as this is very similar.
4