Morse code was invented by Samuel Morse in 1832. Letters and numbers are represented by a series of dots and dashes - a dash sound lasts three times longer than a dot sound.

Morse Code Translator:

Morse code is a common code that is used to encode messages consisting of letters and digits (this project only handles letters). Each letter consists of a series of dots (using asterisks for ease of use here) and dashes; for example, the code for the letter a is *- and the code for the letter b is -***.

  • Store each letter of the alphabet in a node of a binary tree of height 5. The root node is at level 1 and stores no letter. The left node at level 2 stores the letter e (code is *), and the right node stores letter t (code is -). The 4 nodes at level 3, from left-to-right, store the letters with codes (**, *-, -*, --). If your tree is visualized, it would look like: see image.
  • To build the tree above, read a text file in which each line consists of a letter followed by its code (i.e., b -***) and add the node appropriately to the tree using the morse code. The letters should be ordered by tree level, from left-to-right (i.e., e, t, i, a, n, m, etc. where each letter is on its own line with the code as described previously).
  • To find the position to add for a letter in the tree, use the code and branch left for a dot (*) and branch right for a dash (-).
  • To decode the message using the MorseCodeTree, translate each letter using the tree (branch left for a dot, branch right for a dash). Make sure you use a space ( ) as a delimiter between coded letters (i.e., **** * *-** *-** --- *-- --- *-* *-** -** translates to helloworld).
Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.