Question: 2 Morse Code ( 3 pts ) In class we learned Morse Code. Because it is not a prefix code, we've seen that a code
Morse Code pts
In class we learned Morse Code. Because it is not a prefix code, we've seen that a code can be interpreted in several different ways. For example, can be interpreted as AA EK RT and so on
We use sc to denote the number of strokes of a letter c Here we only consider upper case letters. The number of strokes are also provided in the parentheses after each letter. There are of course multiple ways to handwrite a letter, and here Im using a common version appearing in many letter written templates. For some reason, for the same morse code, we prefer those interpretations with fewer strokes.
Given a Morse code X a string consisting of and we want to know, among all the possible interpretations of X which one uses the smallest number of strokes. For simplicity, assume we have a unitcost function check X i j c that checks if the substring Xi j is the Morse code for character c For example, operatornamecheckXB checks if the second to the fifth character in X is the Morse code for B
As an example, consider X There are many possible interpretations for X : AA strokes EK strokes RT strokes ETET strokes and so on The fewest strokes we can get is
pts What is the Morse code for word "UCR"? Is there any other interpretations of UCR's code if there's no separator Please list at least three of them, and at least one of them should have length leq Which of them have the fewest strokes?
pts Design an algorithm for the above task: given a Morse coding string X find the one with the fewest strokes among all possible interpretations of X Hint: You can use fi to denote the fewest strokes you could get using first i elements in X
pts What is the time complexity of your algorithm?
pts Use your algorithm to compute: what is smallest number of strokes you can get by interpreting string Assume you only use the following letters A strokes C stroke E strokes G strokes K strokes and T strokes
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
