(Solved) : Write Program Encodes Decodes Morse Code Files Using Binary Tree Morse Code System Encodes Q42742073 . . .

Write a program that encodes and decodes Morse code files usinga binary tree. Morse code is a system that encodes the 26 Englishletters and 10 numeric digits into sequences of dots, dashes, andspaces. Your tree can store the encodings of each letter andnumber, going left for a dot and right for a dash. When yourprogram reads a sequence of Morse code characters, it shouldtraverse the tree in the appropriate direction for each characterand output the letter or number it reaches at the end of eachsequence.

Please include explanatory comments

Encode using a treemap and decode using a bianary tree, musthave client code

public class MorseDecode{ private TreeNode decodeTree; private static final char DOT = ‘.’; private static final char DASH = ‘-‘; public MorseDecode() { . . . } /** * Inserts a letter into the decoding map based on the dot-dash code. */ private void treeInsert(char letter, String code) { . . . } /** * Converts Morse code message into text. */ public String decode(String morse) { . . . } public static void main(String[] args) { MorseDecode decoder = new MorseDecode(); String testString = .–. — -. -.. . .-. — … .- ; System.out.println( testString + decodes to + decoder.decode(testString) ); }}public class TreeNode{ private Object value; private TreeNode left; private TreeNode right; public TreeNode(Object initValue, TreeNode initLeft, TreeNode initRight) { value = initValue; left = initLeft; right = initRight; } // Methods: public Object getValue() { return value; } public TreeNode getLeft() { return left; } public TreeNode getRight() { return right; } public void setValue(Object theNewValue) { value = theNewValue; } public void setLeft(TreeNode theNewLeft) { left = theNewLeft; } public void setRight(TreeNode theNewRight) { right = theNewRight; }}

Expert Answer


Answer to Write a program that encodes and decodes Morse code files using a binary tree. Morse code is a system that encodes the 2…

Leave a Comment

About

We are the best freelance writing portal. Looking for online writing, editing or proofreading jobs? We have plenty of writing assignments to handle.

Quick Links

Browse Solutions

Place Order

About Us

× How can I help you?