
Morse Code Is a Variable-Length Binary Encoding From 1837
Samuel Morse solved the same problem that Huffman solved with his coding algorithm in 1952: assign shorter codes to more frequent characters. The letter E (the most common in English) is a single dot. The letter J is dot-dash-dash-dash. The encoding table const MORSE = { ' A ' : ' .- ' , ' B ' : ' -... ' , ' C ' : ' -.-. ' , ' D ' : ' -.. ' , ' E ' : ' . ' , ' F ' : ' ..-. ' , ' G ' : ' --. ' , ' H ' : ' .... ' , ' I ' : ' .. ' , ' J ' : ' .--- ' , ' K ' : ' -.- ' , ' L ' : ' .-.. ' , ' M ' : ' -- ' , ' N ' : ' -. ' , ' O ' : ' --- ' , ' P ' : ' .--. ' , ' Q ' : ' --.- ' , ' R ' : ' .-. ' , ' S ' : ' ... ' , ' T ' : ' - ' , ' U ' : ' ..- ' , ' V ' : ' ...- ' , ' W ' : ' .-- ' , ' X ' : ' -..- ' , ' Y ' : ' -.-- ' , ' Z ' : ' --.. ' , ' 0 ' : ' ----- ' , ' 1 ' : ' .---- ' , ' 2 ' : ' ..--- ' , ' 3 ' : ' ...-- ' , ' 4 ' : ' ....- ' , ' 5 ' : ' ..... ' , ' 6 ' : ' -.... ' , ' 7 ' : ' --... ' , ' 8 ' : ' ---.. ' , ' 9 ' : ' ----. ' }; The variable-length insight Morse assigned the shortest
Continue reading on Dev.to Beginners
Opens in a new tab




